Could not load file or assembly ‘Microsoft.IdentityModel’


I ran into a problem trying to authenticate with CRM 2011 Online, I received the following error message when I tried to run my code:

Could not load file or assembly ‘Microsoft.IdentityModel Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencie. The system cannot fine the find specified.

The reason for receiving this error is because I don’t have the Windows Identify Foundation Pack installed on my Windows 7 machine.  To resolve this problem, I downloaded and installed the Windows Identity Foundation Pack.

Comments (16)

  1. madenwal says:

    Thanks, this helped me out :)

  2. Sever S. says:

    Correct and useful note.

  3. Cam says:

    At work we usually try to include EVERYTHING a developer may need right in the solution so he can just check the entire thing out on a brand new machine with a stock Visual Studio and it will work.

    Do you have any idea which .dll gets installed with Windows Identity Foundation Pack that, when missing, causes that error? I'd love to just include it instead of having developers install the pack.

  4. James says:

    Thanks, very helpful

  5. Tchak says:

    Now it seems obvious why it can't load it 😀

    Cheers mate

  6. I tried downloading Windows Identity Foundation but it was already on my machine.  I get this error after publishing the site, the site works fine on my localhost. I am using VS2012 and the Target Framework for the site is 4.5.  Could this be the problem?

  7. Raif says:

    And yet another thanks.  Appreciate you writing it up.

  8. Abhishek D says:

    I am facing same problem in windows 8 , 64 bit OS, Not able to register plugins. Getting error.

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

      at Microsoft.Crm.Tools.PluginRegistration.AutoRefreshSecurityToken`2.RenewTokenIfRequired()

      at Microsoft.Crm.Tools.PluginRegistration.ManagedTokenDiscoveryServiceProxy.ValidateAuthentication()

      at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer`1.Initialize(ServiceProxy`1 proxy)

      at Microsoft.Xrm.Sdk.Client.DiscoveryServiceProxy.Execute(DiscoveryRequest request)

      at Microsoft.Crm.Tools.PluginRegistration.CrmConnection.RetrieveOrganizations()

      at Microsoft.Crm.Tools.PluginRegistration.ConnectionsForm.OpenConnection(CrmConnection con)

  9. Himanshu says:

    I am also getting this error. I tried removing the given Reference and then adding it up, but of no Help

    Please suggest.

  10. Sharadhi says:

    Thanks, this helped me too ..

  11. gare2 says:

    Thanks you.

    This was a helpful post.

  12. gare2 says:

    Thank you for identifying the issue.

    You can also include the Windows Identity reference in your project when you build and deploy.   As an earlier commenter mentioned.

  13. JD says:

    Helped me. Thank you.

  14. Naresh says:

    Thanks.. its works

  15. Tony says:

    Thanks… Saved me.  Works perfectly

  16. Peter says:

    Thank you. Spot on