组织服务在开发Dynamics CRM插件的开发人员工具包中为空

本文关键字:开发 工具包 插件 服务 Dynamics CRM | 更新日期: 2023-09-27 18:06:09

我编写了一个插件,该插件在异常中抛出OrganizationService对象,以检查它是否包含任何用于组织的内容。但我遇到了例外。我附上以下两份,期待您的指导。TIA ! !

代码:

protected void ExecutePostRequestforApprovalCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }
            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService service = localContext.OrganizationService;
            var serviceContext = new OrganizationServiceContext(service);
            throw new ArgumentException("Exception sent:"+service.ToString());
}
异常:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.ArgumentNullException: Value cannot be null.
Parameter name: The plug-in type could not be found in the plug-in assembly: approveCheckListTest.Plugins.PostRequestforApprovalCreateDetail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>CallStack</d2p1:key>
      <d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">   at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()
   at Microsoft.Crm.Application.Platform.ServiceCommands.CreateCommand.Execute()
   at Microsoft.Crm.Application.Platform.EntityProxy.Create(Boolean performDuplicateCheck, Guid auditingTransactionId)
   at Microsoft.Crm.Application.Platform.EntityProxy.Create(Boolean performDuplicateCheck)
   at Microsoft.Crm.Application.Forms.AppForm.SaveEntity(EntityProxy entity, FormEventId eventType, String redirectPath, Boolean performDuplicateCheck)</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>System.ArgumentNullException: Value cannot be null.
Parameter name: The plug-in type could not be found in the plug-in assembly: approveCheckListTest.Plugins.PostRequestforApprovalCreate</Message>
  <Timestamp>2015-08-04T08:32:19.3215616Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>
[approveCheckListTest.Plugins: approveCheckListTest.Plugins.PostRequestforApprovalCreate]
[613491a3-813a-e511-800b-005056b743f7: PostRequestforApprovalCreate]
</TraceText>
</OrganizationServiceFault>

组织服务在开发Dynamics CRM插件的开发人员工具包中为空

该错误通常是由服务器和Visual Studio项目之间的Microsoft.Xrm.Sdk SDK版本不一致引起的。

删除参考,重新构建项目并添加正确的SDK版本作为参考。重新构建并使用插件注册工具导入。