私は学習Dynamics 365プラグインの開発です。Dynamics 365サンドボックスモードで厳密に型指定されたentiyを更新するときにプラグインSDKが例外をスローする
問題:強く型付けされたエンティティでUpdateメソッドを呼び出すと、例外が発生します。正確なエラーメッセージは次のとおりです。
"System.Runtime.Serialization.SerializationException:のMicrosoft Dynamics CRMがエラーを経験している管理者やサポートのためのリファレンス番号:#1330ADC1"
マイセットアップ: 私のソリューションが含まれていますシンプルなプラグイン。強く型付けされたエンティティアカウントを作成しました。プラグインの隔離モードはサンドボックスです。 Telephone1フィールドは文字列です。
私はCRMからアカウントを取得し、Telephone1フィールドを新しい値に更新し、アカウントレコードを更新します。シンプル:)
コード:
public class PostOperationaccountUpdate: IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var organisationService = serviceProvider.GetService(typeof (IOrganizationService)) as IOrganizationService;
var context = serviceProvider.GetService(typeof (IPluginExecutionContext)) as IPluginExecutionContext;
var entityAccount = context.InputParameters["Target"] as Entity;
var id = entityAccount.Id;
var account = organisationService.Retrieve("account", id, new ColumnSet("telephone1"));
//Get a strongly typed version of the Account entity
var dbAccount = account.ToEntity<Account>();
//Update the telephone1 field using the "old" way
account["telephone1"] = "1234567890";
try
{
//This will pass
organisationService.Update(account);
//Update the strongly typed Account
dbAccount.Telephone1 = "plop";
//This fails
organisationService.Update(dbAccount);
}
catch (Exception ex)
{
throw;
}
}
}
私が試してみました何: を - >私はなしに、プラグインの分離モードを変更した - これは働きます!ベストプラクティスによると、それは推奨されません助け ため
おかげチャールズ
ん遅くするとサンドボックス内で動作しますか? – Alex
厳密に型指定されたAccountクラスは、偶然別のDLLにありますか?もしそうなら、あなたはプラグインDLLにそれをilmergeする必要があります。 Account.csクラスをプラグインプロジェクトに直接追加することで、それをすぐにテストできます。 – Polshgiant
@Alex:はい。もし私がそれを遅くしてサンドボックスにしたら、それは動作します – h4ck3r8ug5