I got this error in an ASP.NET MVC 4 application after installing DotnetOpenAuth via the Package Manager Console:

Could not load file or assembly 'DotNetOpenAuth.Core, Version=, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The application was actually upgraded earlier from ASP.NET MVC 3, i.e. it was not autogenerated by Visual Studio 2012. The pre-binding info in the exception was:

=== Pre-bind state information ===
LOG: DisplayName = DotNetOpenAuth.Core, Version=, Culture=neutral, PublicKeyToken=2780ccd10d57b246
LOG: Appbase = file:///
LOG: Initial PrivatePath = \bin
Calling assembly : Microsoft.Web.WebPages.OAuth, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
LOG: This bind starts in default load context.
LOG: Using application configuration file: \web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: DotNetOpenAuth.Core, Version=, Culture=neutral, PublicKeyToken=2780ccd10d57b246
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core.DLL.
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core/DotNetOpenAuth.Core.DLL.
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

The key pieces of information here are at lines 3 and 7. Basically, Microsoft.Web.WebPages.OAuth needs DotNetOpenAuth.Core, but the DotNetOpenAuth.Core I have is versionĀ

The solution is to add these lines under the <runtime>/<assemblyBinding> section of the root Web.config:

	<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
	<bindingRedirect oldVersion="" newVersion="" />
	<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
	<bindingRedirect oldVersion="" newVersion="" />

The above solution works for other packages that ASP.NET MVC 4 depends on. For example, if you upgrade WebGrease from to, you have to add this to the <runtime>/<assemblyBinding> section:

	<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
	<bindingRedirect oldVersion="" newVersion="" />
Tagged with →  
Share →

7 Responses to APS.NET MVC 4: Could not load file or assembly DotNetOpenAuth.Core, Version=

  1. Carl says:

    Thank you. I went on a wild goose chase following suggestions about the GAC and replacing DLLs. This saved me a lot of time.

  2. Thorne says:

    Thanks it was spot on.

  3. Srikanth says:

    Wow, it worked!! Thank you..

  4. Pablo says:

    Thanks, it works. And the response was very clear.

  5. ihsan says:

    Thanks,it works

  6. Dharmesh says:

    Thanks, it works

  7. Dani says:

    I’m suffering same problem but with vb windows application, can you give me the solution please?

Leave a Reply

Your email address will not be published. Required fields are marked *

× 3 = twenty one

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>