CRM 2011 Plugin causing “Could not load file or assembly ‘Microsoft.Xrm.Client” error

I know I am not the first person to come across this error.  I see a lot of solutions out there to resolve this error.  This is how I resolved this error.

First for a little back story.  I have not done a lot with plugins. In fact the only plugins that I had running in my system were implemented on the initial install of CRM 4.0 and they were done by the consulting company who did our install.  I finally had a need to build my own plugin.  I will be writing a blog on the plugin that I had to write because it solved a major issue that I was having with connector.

So in the sdk there is a nice walk through of creating a plugin. You can also find it here

Everything was working perfectly I followed the instructions perfectly.  except for one apparently very important step.

  1. Add all dependent assemblies to the GAC on the server. To do this, open your project’s Debug/binfolder and copy all *.dll files except for the main PluginWalkthrough.dll file to the GAC on the server.

Not doing this step did not impact the registration of my plugin.  This also did not impact the running of my plugin.  Everything was going along just fine, until I needed to run my Customer Portal  from adx studios.  I had not realized that a plugin was registered for the portal.  I also did not think that my plugin would have any impact on the portal.

I ran the portal and the site crashed.  Of course all I was getting this error to start with…

The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs

I had seen this before. It was annoying.  Where…?  Do what???  So after a little digging I found the solution on stack over flow

Here is the gist of it.  Go on to the CRM Server.  Find your program files folder and navigate to

\Program Files\Microsoft Dynamics CRM\CRMWeb

Open the Web.cofig file and find this tag <system.serviceModel>

make it look like this

<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
                                          <serviceDebug includeExceptionDetailInFaults=”true”/>

Now you will get more relevant error messages.  And the one I was getting is that the application

Could not load file or assembly ‘Microsoft.Xrm.Client….

I thought back to the documentation and the line about the GAC.  Well it looks like I was going down that road.  In Server 2003 you could easily register assemblies in the GAC with a simple drag and drop.  Well not anymore in Server 2008.  You have to use the Gacutil.exe.  I was just looking for some simple step by step how too’s on this and I could find a lot of almost step by step, but they were all missing little pieces of info that I did not know.

so this is what I did.

Open cmd and type cd C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools

this should put you in the folder with the gacutil.exe.  To make sure you are there.  You can physically navigate to the folder or type this

gacutil.exe /?

this should spit out a bunch of help information and you know you are in the right place.

now type gacutil.exe /i fullpath and name of your dll

replace “fullpath and name of your dll” with the path and name of your dll.

You should see

Assembly successful added to the cache.

If you see this error

Failure adding assembly to the cache: this assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Then you are using the wrong gacutil for the version of .net you compiled the dll in.

I ran the cmd for all the dependant dlls in my bin folder for my plugin and registered them all in the GAC, restart IIS and now everything is all back to normal 😀

About dorothyjarry

Super Dots
This entry was posted in CRM, CRM 2011, Dynamics. Bookmark the permalink.

One Response to CRM 2011 Plugin causing “Could not load file or assembly ‘Microsoft.Xrm.Client” error

  1. Evelyn says:

    Thank you for explaining how to use it 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s