Could not load file or assembly 'WebGrease' or one of its dependencies

蓝咒 提交于 2019-11-28 19:08:04

I had the same issue.

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.

I had to run Update-Package -Reinstall Microsoft.AspNet.Web.Optimization

That updated my web.config and all references

Check the contents of runtime/assemblyBinding section in web.config. I found incorrectly registered dependentAssembly elements after installing Kendo UI package. I manually removed duplicates and the problem disappeared.

Replace:

<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />

For:

 <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
Salman Saiyad

This problem occurs when your referenced dll may different from your web.config file configuration. You need to reinstall the dll.

Just update WebGrease to 1.6

PM> Update-Package WebGrease -Version 1.6

My situation was this: worked fine on my dev machine but got this same "webgrease missing" error on the host platform. My solution:
1. Removed all .dll's from the \bin directory
2. Removed all of the references from web.config.
3. As I refreshed the home page and got a "some-next.dll was missing" error, I copied that some-next.dll to the bin directory AND added the reference to web.config for each "fresh" dll

Note: Look at the WebGrease.dll properties | details tab - make sure the product version matched the <dependentAssembly>. In my case, it was this:

<dependentAssembly>
  <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-1.5.1.25624" newVersion="1.6.5135.21930" />
</dependentAssembly>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!