0
votes

I'm creating an ASP web app that will connect to CRM. but I got error every time I run my application: ERROR Could not load file or assembly 'Microsoft.Xrm.Client

Using the Microsoft.Xrm.Client.dll Version: 5.0.9690.2165 as reference give us an error :

Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

But when we replace the dll with Microsoft.Xrm.Client.dll Version: 5.0.9689.2166 as reference give us an error:

Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9690.2165, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

And I cant add both version as my Reference. I'm confused what version on of the Microsoft.Xrm.Client.dll Version to use to debug this Error.

1
Which CRM are you using, CRM Online ? CRM On-Premise ? - Dot_NET Pro
I tried both Online and On-Premise. But same result. - LennuJ Kram
use the nuget package or download the latest sdk and use also all the other libraries from it - Guido Preite
@Guido can you please give me a link to download to make sure were having same reference. Thanks sir. - LennuJ Kram

1 Answers

0
votes

Please let us know if you were able to resolve this, if so what was the reason.

In my case, i had a plugin which was used to create users in MSCRM.

I had two different organizations, Org A and Org B.

  1. As per functionality it was needed that whenever a new user is created in Org A same should be created in Org B

  2. So we registered the plugin on Org A

  3. As the organization B was created using database restore the same plugin was also registered in org B

  4. So, on Creation of user in Org A, plugin of Org A was triggered, which tried to create User in Org B

  5. At the same time as the same plugin was available in Org B it was also triggered.

  6. As per my understanding Org B also tried to load the assembly Microsoft.Xrm.Client.dll which was currently being used by plugin of Org A.

So we were getting the error

Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Hope this will help somebody!