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!
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!
I had the same error come up with my project as well. It turns out that there were several "XYZ-Copy.dll"'s in my bin directory that was causing the problem. I deleted all XYZ-copy.dll files and it worked.
我只是删除了C:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ Temporary ASP.NET \\中的所有内容...如果您使用框架4,请尝试C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4。 0.30319 \\ ASP.NET临时文件\\
I tried installing the latest version from Nuget:
install-package WebGrease
ReBuild the application twice and the error went away.
hope it help somebody!
This was resolved by
1) running the Package Manager Console
2) in Console, type: 'Install-Package Microsoft.AspNet.Web.Optimization'
Which resolved all the incorrect dependencies and Successfully added Microsoft.AspNet.Web.Optimization to the Project
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.