I have an MVC5 Web api project. I am getting following error after deployment,

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.The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

In My project I have following references,

System.Web.Mvc - 5.1.0.0

System.Web.Razor - 3.0.0.0

WebGrease - 1.6.5135.21930

Also I have included Following section in my Web.config file,

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
  </dependentAssembly>

I have tried with following steps but still not working ,

Uninstall-Package Microsoft.AspNet.Web.Optimization

Uninstall-Package WebGrease

Install-Package Microsoft.AspNet.Web.Optimization

Update-Package WebGrease

I have referred many links on technical blogs but still getting the same error after deployment.

Can any one help me to find the solution?

Thanks

1

There are 1 answers

0
Dmitry On

In my case the reason was in folders/configs hierarchy in an application. Try to check that binding redirect is in your root web config.

As an example:

/AppRoot
Web.config1
/Areas/SomeArea
Web.config2

Make sure that you have correct binding redirect in Web.config1.

Hope this helps.