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

标签 asp.net asp.net-mvc-4 iis-7.5 webgrease

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

Upgrading WebGrease to version 1.3.0 gets me error

我的生产服务器上有以下绑定(bind)重定向:

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

我的生产服务器上有 Microsoft ASP.NET Web 优化框架所需的以下 DLL:

  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

最佳答案

终于弄清楚为什么这对我不起作用,尽管其他用户说这对他们有用。

我的 web.config 文件中有以下绑定(bind)重定向以强制 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>

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

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

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

终于!!

关于asp.net - 将 WebGrease 升级到版本 1.3.0 仅在生产服务器上导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16866676/

相关文章:

c# - URL编码和解码

javascript - DataTables 未捕获类型错误 : Cannot set property '0' of undefined

c# - URL 重写不起作用

c# - MVC 4 - 更改密码错误 : "Index (zero based) must be greater than or equal to zero..."

c# - 静态内容不在 Asp.net MVC 中缓存

IIS7.5 OutputCacheModule 内核缓存 'public' 忽略 URL

iis - 将静态内容重写到 IIS 中的不同域

c# - 像这样从另一个线程发送电子邮件可以吗?

javascript - IE11 FormData AJAX Post with File 在 401 后挂起

c# - 使用 MVC4 + Entity Framework 4 更新模型