DavidSpot Blog

Developer, super curious, a dog lover, sports fan and techie guy


Fixing error: Could not load file or assembly '[type]' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

If you're having an error similar to the image below the source of the problem may be on your web.config that's wrongly doing a biding to a nonexistent version of the dll that's causing the error.

I'll give an example that happened to me recently.

I was getting this error:

Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040

 

I had this error before and the cause was a bad merge in our code repository server witch is TFS. I've compared the two versions and notice that bindingRedirects was changed to a new version.

Local version:

<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>


Server version:

<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>


As you can see, the change between versions was the source of the bug. Just to be safe (and because I'm curious) I checked the local dll version that was on my local environment, and voilá, the dll file version was 2.0 and not 3.0.