Troubleshooting "The located assembly's manifest definition does not match the assembly reference"

You may get this error message in several compile-time or run-time situations. This article will list actions required resolve the issue. Action are listed from easy-to-guess (easy-to-resolve) to hard-to-guess (hard-to-resolve) order.

Actions Required Resolve the Issue

With doing these steps, the error message goes away and you can continue to compile or run the application.

  • Make sure that the assembly which you have been add to the project references really exists with the correct version.
    • If it's added from a dll file in file system:
      • Right-click on the reference in Visual Studio->Solution Explorer->Project->References then click Properties. In Properties see what is Path.
      • Go to that Path via your operating system explorer and make sure that the dll file exists there.
      • If the dll file exists there then right-click on it and click Properties. Now make sure that the dll version is right and you (the user which have been ran Visual Studio) have enough security permissions to read and work with file.
    • If it's added from a registeration to GAC:
  • Make sure that all of the referenced assemblies have been built with the correct version of the shared assembly. When you change a shared assembly version, you should build others from down (less-dependant) to top (most-dependant). For example say app.exe uses dll1.dll and in order dll1.dll uses dll2.dll and so so. When you change dll2.dll, build dll1.dll with the new one then finally build the app.exe.
  • Make sure that a cached dll is not used. Remove the dll from references and add it again.
  • Make sure that the host solution targeted .NET Framework version is not less than the used assembly. For example if app.exe uses dll1.dll and ddl1.dll is a .NET Framework 3.5 assembly then app.exe should be .NET Framework 3.5 or above.
  • Make sure that the assemblies in web.config or machine.config are updated and synchronized with the real one in project references and operating system file in order to your changes. These start with "<assemblies> <add assembly=..." in the config file.
  • Make sure that there is not an old version of the dll in "%WINDOWS%\Microsoft.NET\Framework\.NET Framework Version]\Temporary ASP.NET files" folder. You can delete this folder files, they are temporary.
  • Make sure that there is no an old version of the dll in GAC. You can use Microsoft Global Assembly Cache Tool which mentioned above.
  • Make sure that licenses.licx contents are updated and synchronized with real one in project references and your changes. If the project has a file named "licenses.licx" then Visual Studio will compile it too with LC.exe (License Compiler). Make sure that this file contents (listed assemblies) are updated and synchronized with your changes. For more info about LC.exe you can refer to http://msdn.microsoft.com/en-us/library/ha0k3c9f(v=vs.80).aspx
  • If you get this error at run-time then make sure that you use reflection well. A powerfull tool for diagnosing this can be found at http://msdn.microsoft.com/en-US/library/e74a18c4(v=VS.80).aspx (Microsoft Assembly Binding Log Viewer).

References