Mark Cassar Mark Cassar - 2 months ago 23
ASP.NET (C#) Question

Could not load file or assembly XXX or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

When running an Asp.Net MVC application locally, everything runs fine but when application is deployed on the server, I am getting this error.

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


I have just recently added the
System.Web.Optimization
framework through NuGet which makes use of WebGrease.

If I check references, my version of WebGrease is 1.5.2.14234 which is higher than the one complaining about not finding - 1.5.1.25624.

Within the root web config, I have the following underneath the runtime tag:

<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>


If I check the WebGrease.dll within the bin folder on the server, the version of the WebGrease DLL is 1.5.2.14234. Who could be requiring the other version 1.5.1.25624 and any idea how this can be solved?

Thanks a lot!

Answer

It was a mistake from our end whereby the actual root web config on the server had an incorrect dependentAssembly tag which consisted of:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>

and not:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>

hence why the error was being issued!