Assembly's manifest definition does not match assembly reference
Asked Answered
O

5

21

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

Ogive answered 7/1, 2014 at 17:56 Comment(0)
O
38

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

Ogive answered 7/1, 2014 at 17:56 Comment(1)
Also: try Update-Package -Reinstall Antlr in case the above doesn't workFascia
W
13

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.

Wien answered 2/10, 2018 at 15:36 Comment(1)
Upvoted because this pointed me in the right direction. This is crazy but we are using Newtonsoft.Json 10.0.2.0 (no, we can't upgrade right now) but in the redirect we have to specify newVersion="10.0.0.0" because internally 10.0.2.0 reports as 10.0.0.0.Entoil
P
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.

Phosphorus answered 6/2, 2018 at 16:20 Comment(0)
P
1

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.

Paganism answered 28/3, 2016 at 7:16 Comment(0)
B
1
Update-Package -Reinstall Antlr

worked for me...

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

Billow answered 6/9, 2018 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.