Search code examples
c#asp.netbundling-and-minificationasp.net-optimizationwebgrease

Could not load file or assembly 'WebGrease, Version=1.5.1.25624 - Or any other version


I have the same issue found in these questions

Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

Could not load file or assembly 'WebGrease' one of its dependencies. The located assembly's manifest definition does not match the assembly reference

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

None of the answers in these seem to help.

I have a WebForms project Running .Net 4; not MVC.

I am adding bundling & minification using Microsoft Web Optimization, along with its dependencies.

I am receiving the 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 tried changing the version of web grease, and also web optimization. None are working.

These images show my current references, web config and other info:

Web Grease: enter image description here

Web Optimization enter image description here

Web Config enter image description here

Packages Config enter image description here

I am trying to apply my bundle by using the code below, in my master page:

<asp:PlaceHolder runat="server">
    <%: System.Web.Optimization.Scripts.Render("~/JS/Global") %>
    <%: System.Web.Optimization.Styles.Render("~/CSS/Global") %>
</asp:PlaceHolder>

Anybody have any idea how I can get this working? I don't mind using an older version of the libraries; just can't seem to find one that isn't causing the issue.

Could it be the version of NewtonSoft.Json?

Update

So no matter what versions I install, I get the exact same message, right down to the version.. Can't seem to figure where the issue lays


Solution

  • Why you redirect Newtonsoft.Json version binding to version 7.0.0.0. There is no such version in your packages. Remove that redirection or add appropriate version of Newtonsoft.Json.