Upgrading WebGrease to version 1.3.0 gets me error
Asked Answered
D

14

44

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.

Distributor answered 29/11, 2012 at 5:11 Comment(1)
Some of the solutions below, involve using a bindingRedirect to force the System.Web.Optimization assembly to instead bind to the newer version. But for some users it didn't work - including me. I figured out that the binding redirection in the web.config was being ignored. See my answer in this post on how to fix that. stackoverflow.com/questions/16866676Busterbustle
R
63

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.

Reareace answered 23/1, 2013 at 19:32 Comment(6)
This is the correct answer. The reason this works is because Microsoft.AspNet.Web.Optimization has an update that is in prerelease therefore it does not show up in your update list. After doing this process, look at the nuget package and you will see that it is called Microsoft.AspNet.Web.Optimization.1.1.0-alpha1. This alpha version matches up with the new version of webgrease but if you dont have you package manager configured to show prerelease packages you will never see the update for it.Hudspeth
This answer solved my problem. Uninstalling Optimization and WebGrease, then reinstalling, seemed to fix it.Ddt
Thanks man! +1 But that's really a pain in th @ss to experiment with all things we have to do... I don't like it it all.Mi
-1 this worked locally, but reappeared when deployed, so bewareHals
In my case, I only needed to execute the first step, i.e. 'Install-Package Microsoft.AspNet.Web.Optimization', and this fixed my issue.Hothead
looks like my Webgrease updated to 1.6 and this has caused me about 15 hours of trouble.Runthrough
R
17
<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>
Roca answered 20/2, 2013 at 9:34 Comment(0)
I
4

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).

Icebound answered 29/11, 2012 at 5:29 Comment(1)
I have assembly redirect in web.config <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> </dependentAssembly>Distributor
L
3

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.

Lour answered 13/12, 2012 at 4:41 Comment(0)
S
3

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" />
Substantiate answered 18/4, 2013 at 17:20 Comment(0)
H
2

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!

Hals answered 23/4, 2013 at 18:51 Comment(0)
P
1

I had a similar issue except it wasn't an error but a warning. After updating WebGrease to 1.3.0, a build put the warning source on the declaration. After ensuring that I had the appropriate assembly redirect in my web.config file, I eventually created a new _Layout.cshtml view and saved over the old file with the exact same razor markup as was in the previous (copy/paste). After that, the warning went away.

I'm not exactly sure what the warning was all about but try copying your code in your file, pasting it into a new file and overwriting the original.

If anyone has any insight as to why this works, I'm all ears.

Pulsation answered 8/12, 2012 at 21:25 Comment(0)
S
1

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!

Silvereye answered 9/1, 2013 at 17:9 Comment(0)
W
1

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.

Wafd answered 31/5, 2013 at 14:19 Comment(0)
O
0

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.

Orthodoxy answered 12/1, 2013 at 17:48 Comment(0)
U
0

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!!!

Unriddle answered 1/4, 2013 at 15:25 Comment(0)
J
0

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.

Jacie answered 24/4, 2013 at 5:38 Comment(0)
D
0

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>
Davedaveda answered 7/5, 2013 at 2:4 Comment(0)
W
0

In my case all this methods didn't work. Finally I resolve this problem by uninstalling Microsoft.AspNet.Web.Optimization and WebGrease Packages via Package Manager, then I open my project file (.csproj) in notepad and delete all entries related to this two Packages, turn outs that there was problem. Finally I install this two packages via package manager again and run project. All work's fine now.

Wolgast answered 17/3, 2014 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.