Assembly's manifest definition does not match assembly reference

白昼怎懂夜的黑 提交于 2019-11-28 02:49:23

问题


I updated all the packages of my MVC project and I got the following error:

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

Building the project with a razor (.cshtml) file open gave me more errors


回答1:


Here's how I managed to solve it:

Go to the solution explorer and choose Antlr under References, right-click and say properties. Make sure the file version is the same the compiler is looking for. In my case, MSBuild wanted version 5.5.0.2, but the reference properties showed an earlier 2.x version.

All I had to do is go to the package manager console and type:

PM> update-package Antlr

Then build the project again, and in-case you get the same error for more assemblies, update them as well. Your issue will be resolved




回答2:


This can happen if you have a rogue binding redirect in your configuration file, that points to a version you don't have.

In our case, we were referencing the PostSharp 5.0.50 Nuget package, and the following was present in our config file, which was causing it to look for PostSharp version 5.0.51 instead.

<dependentAssembly>
  <assemblyIdentity name="PostSharp" publicKeyToken="b13fd38b8f9c99d7" culture="neutral"/>
  <bindingRedirect oldVersion="0.0.0.0-5.0.51.0" newVersion="5.0.51.0"/>
</dependentAssembly>

I fixed it by removing the binding redirect, because it was not necessary. You could also fix it by changing the version of the binding redirect to the same version as the Nuget package you've referenced.




回答3:


I had the same error with my MVC 5 application. Tried everything from,

  • Installing and Reinstalling the Antlr packages
  • Deleting the %TEMP% data.

Fianlly i was able to solve the problem by simply deleting all the dlls from my project's bin folder and building the project again. Though I am still not sure about the real reason for this reference error.




回答4:


I tried the above solution to update a specific package but that had no success but updating all packages did work. Using the package manager console;

update-package -Reinstall

Followed by a rebuild of the solution.




回答5:


Update-Package -Reinstall Antlr

worked for me...

Also, when publishing ensure "Delete Existing Files" checkbox is checked.



来源:https://stackoverflow.com/questions/20978519/assemblys-manifest-definition-does-not-match-assembly-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!