Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an MVC4 Web API project. While running the service project I am getting an error

Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I have added the WebGrease.dll file and still its coming error

And tried with changing web.config

<bindingRedirect oldVersion="0.0.0.0-1.3.0.0"/>"

And

<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
like image 247
Jidheesh Rajan Avatar asked Nov 08 '13 04:11

Jidheesh Rajan


4 Answers

I know it's kind of late for the OP but I ran into the same problem while trying out the Bootstrap 3 for MVC 4 NuGet package, in my case it had something to do with the Microsoft.AspNet.Web.Optimization package, and managed to find a simple solution.

Try executing the following commands in the package manager console:

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

The first two lines had no effect for me since those packages were already installed and updated by the Bootstrap 3 for MVC 4 package, but I ran them anyway and then it all compiled and ran great.

like image 184
c0y0teX Avatar answered Nov 17 '22 05:11

c0y0teX


This error is because Microsoft.AspNet.Web.Optimization 1.1.3 internally references WebGrease 1.5.1.25624 even though the Nuget package, itself, has a dependency on WebGrease 1.5.2.14234. Someone clearly messed up while creating the Nuget package.

To solve this, add this assembly binding in your Web.Config.

  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.5.1.25624" newVersion="1.5.2.14234" />
  </dependentAssembly>
like image 63
André Pena Avatar answered Nov 17 '22 06:11

André Pena


Have you tried through NuGet ?

Install-Package WebGrease -Version 1.5.1

or

Install-Package WebGrease -Version 1.5.2
like image 47
Fernando Vezzali Avatar answered Nov 17 '22 05:11

Fernando Vezzali


For me, none of above scenarios worked.

After trying for two days, finally i found the solution.

What i did was, i uninstalled Microsoft.AspNet.Web.Optimization and WebGrease both.

I knew that this optimization assembly internally refers to WebGrease 1.5.1. So i chose a version of optimization which does not refer to WebGrease 1.5.1.

I ran following commands in order to make everything work.

Uninstall-Package Microsoft.AspNet.Web.Optimization
Uninstall-Package WebGrease
Install-Package Microsoft.AspNet.Web.Optimization -Version 1.1.0

I hope i will be able to be a good help for someone for whom above solution does not work.

Cheers!

like image 16
jparthj Avatar answered Nov 17 '22 06:11

jparthj