将WebGrease升级到版本1.3.0仅在生产服务器上导致错误

Bri*_*den 4 asp.net iis-7.5 asp.net-mvc-4 webgrease

首先,回答这个问题,不要解决我的错误:

将WebGrease升级到1.3.0版本会让我出错

我的生产服务器上有以下bindingredirect:

<dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

我在生产服务器上有以下DLL,它们是Microsoft ASP.NET Web Optimization Framework所必需的:

  1. System.Web.Optimization.dll 1.0.0.0(这不是预发布版本)
  2. Antlr3.Runtime.dll 3.3.1.7705
  3. Webgrease.dll 1.3.0.0

我收到以下错误:

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)

我已经检查了GAC,我已经删除了所有临时ASP.NET文件夹,我已经尝试newVersion从我的配置中删除该属性<bindingRedirect>.我不确定是什么告诉ASP.NET寻找WebGrease 1.0

Jaa*_*ans 8

终于找到了为什么这对我不起作用,尽管其他用户说这对他们有效.

我在web.config文件中进行了以下绑定重定向,以强制System.Web.Optimization程序集使用较新的版本:

<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>
Run Code Online (Sandbox Code Playgroud)

它就像其他用户一样,但它没有用.然后我使用融合日志查看器(Fuslogvw.exe)来找出更多信息,并发现绑定过程甚至没有查看重定向指令.

最后发现根目录上一定不能有XML命名空间.... 如果我从我的<configuration>元素中删除以下内容它可以工作:xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

另外,只需确保在<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">元素上指定了以下XML命名空间.

最后!!