Search code examples
asp.netasp.net-mvc-4iis-7.5webgrease

Upgrading WebGrease to version 1.3.0 causes error only on production server


First off, answers to this question,do NOT solve my error:

Upgrading WebGrease to version 1.3.0 gets me error

I have the following bindingredirect on my production server:

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

I have the following DLL's on my production server that are required for the Microsoft ASP.NET Web Optimization Framework:

  1. System.Web.Optimization.dll 1.0.0.0 (this is NOT pre-release version)
  2. Antlr3.Runtime.dll 3.3.1.7705
  3. Webgrease.dll 1.3.0.0

I am getting the following 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)

I have checked the GAC, I have deleted all Temporary ASP.NET folders, I have tried removing the newVersion attribute from my config <bindingRedirect>. I am not sure what is telling ASP.NET to look for WebGrease 1.0


Solution

  • Finally figured out why this was not working for me despite other users saying that it was working for them.

    I had the following binding redirection in my web.config file to force the System.Web.Optimization assembly to use the newer version instead:

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

    It was just like other users had, but it didn't work. Then I used the fusion log viewer (Fuslogvw.exe) to figure out more information and discovered that the binding process didn't even look at the redirect instruction.

    Finally figured out that there must not be an XML namespace on the root ... . If I remove the following from my <configuration> element it works: xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

    Also, just make sure you have the following XML namespace specified on the <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> element.

    Finally!!