web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Visual Studio project referencing two different versions of CRM

(0) ShareShare
ReportReport
Posted on by 985

Hi all

I am writing a small application for a client to transfer emails and their related attachments from their archived on-prem CRM 2011 system to their new CRM Online instance. I figured I would write a console app with the CRM 2011 references in the console app, then a class library holding the helper functions to transfer the data into CRM Online, to keep some separation between the two versions of the SDK.

However, while the two projects work individually, when I make a reference between the console app project and the class library in the same solution, when I try to retrieve data from CRM 2011 I get the error message 

Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=8.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)

From this it appears that it is trying to use the CRM Online version of Microsoft.Xrm.Sdk instead of the referenced CRM 2011 one. 

Anyone know how I can get the solution to work properly while referencing both versions of Microsoft.Xrm.Sdk?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi Brad,

    So, you can't have VS reference two different versions of the same assembly. There is a trick though. If you set the assembly bindings in your config file you can tell the code to ignore the version it's looking for and to use version X instead. 

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

    With this snippet in your config file, you're telling it that any code looking for CRM 2011 to 2016 should go ahead and use the 2011 version (or whatever version you have the newVersion set to). You'd do this for your Microsoft.Xrm.Sdk dll, and repeat the dependentAssembly node for any other conflicts.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

      Aiden

  • Verified answer
    Brad Sprigg Profile Picture
    985 on at

    Thanks for the prompt replay Aiden, I appreciate it. I ended up getting around it by using the CRM 2013 versions of the SDK assemblies, that appears to work for both versions for the entities I am touching.

  • GandeShiva Profile Picture
    105 on at

    Thanks. It worked fine for me.

  • RajatSharmaRaj Profile Picture
    on at

    This issue comes up when developer user XRM.SDK.dll from newer SDK but using the CRM.SDK.Proxy.dll from the older version.

    Here simply have to update the reference of CRM.SDK.PROXY.dll with assembly from newer SDK.

  • KrisTurek Profile Picture
    5 on at

    Config file to what and where do I locate it at?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans