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-30 23:55

It looks like you have reference to older (1.0.0.0?) version of assembly (assuming current version is 1.3.0.0). In this case you need assembly redirect in web.config or better yet recompile your binaries to use latest version.

Another possiblity if latest version shares the same assembly version as old one (1.0.0.0) you need to recompile your code to use the right assembly and make sure correct copy is used (check GAC for wrong one, use fuslogv to investigate what exact file caused the error).

查看更多
再贱就再见
3楼-- · 2019-01-30 23:56
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> </dependentAssembly>

Change the upper code in Web.config to the following

<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0"/> </dependentAssembly>
查看更多
老娘就宠你
4楼-- · 2019-01-30 23:58

It's a problem with Microsoft.AspNet.Web.Optimization (Optimise moving forward).

You need to downgrade WebGrease by uninstalling Optimise and removing any WebGrease assembly redirects from web.config.

Then reinstall Optimise and make sure you don't upgrade WebGrease.

It's a quick fix but it got my build working!

查看更多
闹够了就滚
5楼-- · 2019-01-31 00:00

Here is the answer that has worked for me, and it is a combination of some of the above answers. First install / uninstall / reinstall the following packages:

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

Then make a copy of the contents of ~/Views/Shared/_Layout.cshtml delete the _Layout.cshtml file, recreate it and paste the contents back in.

this is the final fix that has worked for me.

查看更多
Juvenile、少年°
6楼-- · 2019-01-31 00:01

Same deal as Hriju and Nathan (Uninstall, re-install and update), only instead of omitting the newVersion attribute, I kept it. But since WebGrease went from 1.1.0 straight to 1.3.0, there was no need for 1.2.0 (as jenson-button-event had it) (Good luck to JB in Spain, btw).

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

Pedantic? Maybe, but it's always in the details, right? This fixed it for me.

Anyhow, here's to hoping they do it right on the next update.

查看更多
男人必须洒脱
7楼-- · 2019-01-31 00:02

For a Web API project I'm working on what really worked was the following:

  1. Open NuGet package manager, click in Installed packages and then uninstall Microsoft.AspNet.Web.Optimization. It prompts it'll remove WebGrease 1.1.0. Hit Yes.

  2. Now reinstall it clicking NuGet's Online tab and search for Microsoft.AspNet.Web.Optimization.

Now everything is working as expected.

查看更多
登录 后发表回答