I am trying to bundle css and js on a sitecore 9.0.2 solution. I am getting the above run time error when the view calls the Styles.Render method. I am using Web.Optimizations 1.1.3 which is dependent on web grease 1.5.2. The webgrease DLL in my sandbox is version

What I have tried:

Added assembly binding to web.config

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

Added packes to packages.config

<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
  <package id="WebGrease" version="1.5.2" targetFramework="net461" />

Added namespace to views web config:

<add namespace="System.Web.Optimization"/>

I also checked that the razor dll and binding was same as vanilla sitecore and I compared my configs and DLLS against a non-sitecore web app that I was able to get bundling working in easily.

  • Probably check your all projects in the solution and confirm it's using same version
    – Siddharth
    Commented Oct 25, 2018 at 6:21
  • Only one project is using web.optimization and webgrease
    – JKerny
    Commented Oct 25, 2018 at 9:12
  • Have you tried enabling Fusion logging to see more details about why the binding is failing? stackoverflow.com/a/1527249/1304050 Commented Oct 25, 2018 at 11:05
  • Having the same problem. Disappointed to see this unanswered.
    – Michael
    Commented Jul 15, 2020 at 13:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.