1

カスタムエンティティの作成メッセージに応答してタスクを作成するプラグインを作成しようとしています。

CrmSvcUtil.exeを使用してカスタムOrganisationServiceContextを生成しましたが、これを使用してタスクを正常に作成するコンソールアプリケーションテストホストがあります(SDK serverConnect.GetServerConfiguration()を使用してOrganizationServiceProxyを作成します)。

プラグインアセンブリ(サンドボックス化)をオンラインインスタンスにデプロイすると、以下のコードが次のように表示されます。

System.Security.SecurityException:タイプ'System.Security.Permissions.SecurityPermission、mscorlib、Version = 4.0.0.0、Culture = neutral、PublicKeyToken=b77a5c561934e089'のアクセス許可の要求が失敗しました

// Obtain the execution context from the service provider.
var executionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(executionContext.UserId);

//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));

tracingService.Trace("Buiding");

var organizationUri = new Uri("{theuri}/XRMServices/2011/Organization.svc");          
var credentials = new ClientCredentials();
credentials.Windows.ClientCredential = NetworkCredential)CredentialCache.DefaultCredentials;

var organizationServiceProxy = new OrganizationServiceProxy(organizationUri, null, credentials, null);
organizationServiceProxy.EnableProxyTypes();

var context = new CustomContext(organizationServiceProxy);

誰かが私を正しい方向に向けることができますか?

ありがとう

4

1 に答える 1