Tuesday, April 19, 2011

CRM 2011 Publisher Policy / Redirection

While working on a CRM 2011 application I kept getting the following error even though I was not even using the CRM 4.0 SDK file.

Exception information: 
    Exception type: FileLoadException 
    Exception message: Could not load file or assembly 'Microsoft.Crm.Sdk, Version=4.0.0.0, 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)

To get around the problem I put the following redirection binding to the CRM 2011 SDK in the web.config. This runtime info can go anywhere directly underneath the configuration node.

<configuration>
  <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="Microsoft.Crm.Sdk"
                           culture="neutral"
                           publicKeyToken="31bf3856ad364e35" />
         <bindingRedirect oldVersion="4.0.0.0"
                          newVersion="5.0.0.0" />
       </dependentAssembly>
     </assemblyBinding>
   </runtime>
</configuration>

1 comment:

Jeevan Kumar Balija said...

Hi Richard,
This fix works for me, thanks for that.
But i have a different issue after fixing this, the same page works fine in CRM 4.0 without any issue, but when it is accessed in CRM 2011,it says "UserId not found for the current user on the context" though the user exists as CRM User.
The CRM 4.0 is an IFD.
Any idea,pls let me know.
Regards
Jeevan.