Could not load file or assembly 'Microsoft.Xrm.Client

淺唱寂寞╮ 提交于 2019-12-10 14:45:01

问题


I have created a plug-in in CRM. It’s registered successfully. Inside my plug-in I have created a web service with many functions. After successful calling of plug-in step I am getting error-

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies`. The system cannot find the file specified. To solve this issue I have created the New XRM.cs file from crmsvcutil.exe but got the same issue. Searched more about this but no solutions found yet.

NOTE: I am using the Microsoft hosted version of CRM

Here below the reference files which I am using.

  • microsoft.crm.sdk.proxy
  • Microsoft.CSharp
  • microsoft.xrm.client
  • microsoft.xrm.portal
  • microsoft.xrm.sdk
  • System
  • System System.Core
  • System.Data
  • System.Data.Services
  • System.Data.Services.Client
  • System.DirectoryServices.AccountManagement
  • System.Runtime.Serialization
  • System.ServiceModel
  • System.Xml
  • System.Xml.Linq

Is there any way to run my plugin on Hosted version of CRM???

Appreciate if any help :)


回答1:


Microsoft.XRM.Client is usually not needed by the plug-in.
It is needed to connect to CRM from an outside application.
Microsoft.XRM.Client has been removed from the SDK since CRM 2016.

Plugins do not automatically resolve dependencies in your project, they have to already be on the server.

Microsoft.XRM.Client can be placed in the GAC if it is needed by the plugin.

Update for Dynamics CRM 2015
The NuGet package Microsoft.CrmSdk.Extensions contains Microsoft.Xrm.Client.

Update for Dynamics CRM 2016 and Dynamics 365
Microsoft.Xrm.Client is no longer part of the SDK.
The NuGet package Microsoft.CrmSdk.CoreAssemblies contains everything needed for plugin development.

The various parts of the Dynamics CRM SDK are in NuGet.
NuGet is a much better solution than adding Dynamics CRM dlls as project references; especially for source control and team development.




回答2:


I have solved this issue by using this command.

CrmSvcUtil.exe /out:"Xrm.cs" 
               /url:http://crm/Contoso/XRMServices/2011/Organization.svc 
               /namespace:Xrm 
               /servicecontextname:XrmServiceContext
               /servicecontextprefix:Xrm

removing code customization options solved my issue.

/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"



回答3:


Microsoft.Xrm.Client.dll doesn't actually appear to work if running from the GAC. This is because of some dodgy type resolution methods it has that only work if the assembly is loaded locally. I have raised an issue with full details about that here: https://community.dynamics.com/crm/f/117/t/144464.aspx



来源:https://stackoverflow.com/questions/18223890/could-not-load-file-or-assembly-microsoft-xrm-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!