Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :)

like image 504
Anil P Avatar asked Aug 14 '13 05:08

Anil P


3 Answers

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"
like image 86
Anil P Avatar answered Nov 18 '22 01:11

Anil P


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.

like image 32
Bvrce Avatar answered Nov 17 '22 23:11

Bvrce


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

like image 1
Darrell Avatar answered Nov 18 '22 00:11

Darrell