Upgrading WebGrease to version 1.3.0 gets me error

2019-01-30 23:26发布

While upgrading WebGrease to version 1.3.0 gets me error:

Could not load file or assembly 'WebGrease, Version=1.0.0.0, 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)

Source Error:

Line 6:      <title>@ViewBag.Title</title>
Line 7:      @Styles.Render("~/Content/bundles/bootstrap")

How to resolve this error.

14条回答
迷人小祖宗
2楼-- · 2019-01-31 00:07

The binding redirect that worked for me:

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

subtle difference is i didn't include this version (1.3.0.0) in the oldVersion attr.

fail cake!

查看更多
姐就是有狂的资本
3楼-- · 2019-01-31 00:07

To fix this, all i did was to Update the package.config file (WEBMATRIX)

<packages>
  <package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net40" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
  <package id="WebGrease" version="1.3.0" targetFramework="net40" />
</packages>

Cheers!!!

查看更多
叛逆
4楼-- · 2019-01-31 00:08

A combination of the following resolved the issue for me. First, running the following commands on the Package Manager command line (similar to the answer provided by sec_goat, but not exactly the same):

Uninstall-Package Microsoft.AspNet.Web.Optimization
Uninstall-Package WebGrease
Install-Package Microsoft.AspNet.Web.Optimization
Update-Package WebGrease

Then, similar to Hriju, I needed to change this line in my web.config:

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

into this:

<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" />
查看更多
Emotional °昔
5楼-- · 2019-01-31 00:13

Thanks to @roadsunknown. My configuration got hosed after my host machine froze, thus causing my VM to not shutdown properly. To resolve this I uninstalled Microsoft.AspNet.Web.Optimization through NuGet, then had to remove the reference to WebGrease in packages.config, and finally reinstalled Microsoft.AspNet.Web.Optimization through NuGet.

查看更多
看我几分像从前
6楼-- · 2019-01-31 00:13

This is what my runtime section looks like and it works

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.3.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>
查看更多
在下西门庆
7楼-- · 2019-01-31 00:15

I had the same issue. Another developer upgraded the WebGrease package (as well as others), but something didn't sync or get checked in. I edited the package file to remove the references to the existing package. Then I reinstalled via Package Manager. Finally, I updated the packages.

It seems as though packages won't install or update if the packages.config file does not match the files (including proper versions) in your project. No error is given in the Package Manager though, it just fails to update or install packages.

查看更多
登录 后发表回答