Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't access Microsoft.Xrm namespace

I've downloaded CRM Dynamics SDK and keep it in a local directory. In my code, I'm using EntityCollection (amongst other classes related to Xrm namespace), which means that I need to add using Microsoft.Xrm.Sdk;.

The problem is that during compilation I get errors saying that:

The type or namespace name 'Xrm' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

So, I double check that the reference is made and, very accurately, I see that microsoft.xrm.sdk indeed is in my list. Just to be sure, I've removed it and added it again by pointing to the DLL with the same name. To no avail, though... The flabbergasting thing is that my colleague uses the same code and it compiles on his machine (the only difference being that he's on Win 7 and I'm on Win 8).

How do we kill this problem?

like image 630
Konrad Viltersten Avatar asked Sep 11 '12 14:09

Konrad Viltersten


3 Answers

Double check in your project settings to see which Target Framework you are using. If it is .NET Framework 4 Client Profile try changing it to .NET Framework 4.

like image 134
Jason Lattimer Avatar answered Oct 05 '22 01:10

Jason Lattimer


I received this when replacing my crm 2013 dlls with the new 2015 ones.

None of the above solutions worked for me. But what eventually led me on the right track was this warning (it was listed as a warning below the namespace errors):

The primary reference "Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.1"

And when I checked I only had .Net 4.5.1 installed so after installing .Net 4.5.2 Developper pack and switching the target framework of my projects to this everything worked again.

The regular 4.5.2 update is not enough to get this version of .net in VS, you need the developper pack

Source: http://www.syntaxwarriors.com/2015/using-crm-2015-sdk-gives-error-that-xrm-does-not-exist-in-the-namespace/

like image 37
JensB Avatar answered Oct 05 '22 01:10

JensB


I had my framework already set to .NET Framework 4 therefore solution of switching between 4 Client profile and regular 4 did not apply. A trick I did was changing .NET Framework into 3.5 and then back to 4.0. I hope this will help some people.

Thx @Jason Lattimer. Your answer gave me a clue how to solve my problem.

Good luck CRM developers!

like image 31
Falcon Avatar answered Oct 05 '22 00:10

Falcon