lioni jordan
lioni jordan

Reputation: 171

The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

After signing the third parties assemblies and adding them to GAC I am getting the below error: also the Assembly Binder Log Entry shows this error

It says mismatching assemblies not sure how mistnaching as I deleted all obj and bin fold and batch built the application + reimported the dlls.

 Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe

--- A detailed error log follows. 
=== Pre-bind state information ===
LOG: User = AKBARCA\user

LOG: DisplayName = ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)

LOG: Appbase = 

file:///C:/Users/user/Desktop/NhibernateMediumTrust/NhibernateMediumUpgrade/direct/clubstar

terkit v3 preview/ClubStarterKit.Web/

LOG: DEVPATH = C:\ProgramData\Red Gate\.NET Reflector\DevPath

LOG: Initial PrivatePath = 

C:\Users\user\Desktop\NhibernateMediumTrust\NhibernateMediumUpgrade\direct\clubstarterkit v3 preview\ClubStarterKit.Web\bin
Calling assembly : ClubStarterKit.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

Upvotes: 16

Views: 58637

Answers (8)

iJungleBoy
iJungleBoy

Reputation: 5638

I had a different cause: in my case, I had used various nuget package versions previously, and I had an app.config which for some reason had been automatically generated with this kind of content:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
  </dependentAssembly>

So I only had Version 1.1.0.0 installed, but because of this redirect instruction, it looked for 1.1.1.0 even though Visual Studio had the nuget for 1.1.0.0 installed. Changing the newVersion to 1.1.0.0 fixed everything:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.0.0" />
  </dependentAssembly>

Upvotes: 2

Lincoln Pires
Lincoln Pires

Reputation: 348

Hum... I faced something similar with the same error message.

In my case I've updated manually the version of the assemblies.

The error message

In the referenced assembly I had another version...

So, I updated it in the web.config.

Properies of the DLL

This solved my problem.

Your === Pre-bind state information === seems incomplete. Generally it shows the execution and the last line shows the error, so, we can help only sharing our experiences. Example: Last line of the LOG info

I hope someone else facing this problem find this helpful.

Upvotes: 3

Mauro Bilotti
Mauro Bilotti

Reputation: 6242

One way to solve this could be, going under "Manage NuGet Packages for Solution" by doing right click in the solution explorer. Once there, go to "Consolidate" and find the package that is causing the problems. Make sure that all the projects within the solution are using the same version.

enter image description here

Upvotes: 1

Jeremy Thompson
Jeremy Thompson

Reputation: 65564

I got this error using FASTjson:

_jsonConfig = fastJSON.JSON.ToObject<jsonConfig>(jsonConfigFileContents);

It failed on this line:

Type t = Type.GetType(typename);

Which causes an exception in System.RuntimeTypeHandle.GetTypeByName


The problem was a difference in the JSON file compared to the JSON Object Model.

The solution is to re-save the JSON Object Model to file, eg:

string jsonSettings = fastJSON.JSON.ToJSON(JSONObjectModel);
File.WriteAllText(JSONFilePath, jsonSettings);

Upvotes: 0

C. Deng
C. Deng

Reputation: 21

In my case, the error happens when the version specified in web.config's <bindingRedirect> of the dependent assembly (e.g. Newtonsoft.Json) doesn't match the version that is actually in the bin folder. Once the version number in the web.config is updated, the problem is fixed.

screenshot of web.config

Upvotes: 2

bresleveloper
bresleveloper

Reputation: 6068

When I experienced this problem in the past, I deleted all my project's dll's from the gac, rebuilt the solution, then did iisreset and it was solved.

Upvotes: 1

Brij
Brij

Reputation: 13141

I faced similar problem. In my case, I was having multiple projects in my solution.

One of the project was referring EntityFramework 4.0 and that project was being referred in another project that was referring to EntityFramework 5.0. I brought them in sync and the problem got away.

Upvotes: 5

Chris Pratt
Chris Pratt

Reputation: 239290

From my experience, this happens, usually once you've published your app and when you have different versions of nuget packages in play. If this happens to be your situation as well, the best way I've found to fix it is to right-click the solution (not the individual projects) and choose "Manage Nuget Packages". Then, locate the offending assembly in the installed packages. You'll probably see it listed multiple times. Click "Manage" on each of the older versions of the package and uncheck all your projects. Once only the latest version of the package remains in the list. Click "Manage" on this one and recheck any projects that need the package. This will essentially upgrade them all to use the same version of the package and should resolve your mismatch error.

Upvotes: 31

Related Questions