首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将WebGrease升级到1.3.0版本只会在生产服务器上导致错误

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

Stack Overflow用户
提问于 2013-05-31 22:01:45
回答 2查看 8.8K关注 0票数 4

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

Upgrading WebGrease to version 1.3.0 gets me error

在我的生产服务器上有以下绑定元素:

代码语言:javascript
复制
<dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>

我的生产服务器上有下列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文件夹,我尝试从配置<bindingRedirect>中删除newVersion属性。我不知道是什么让ASP.NET去寻找WebGrease 1.0

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-06-12 05:10:37

最后,尽管其他用户说它是为他们工作的,但我终于明白了为什么这不适用于我。

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

代码语言:javascript
复制
<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)查找更多信息,发现绑定过程甚至没有查看重定向指令。

最后,指出根目录上不存在XML命名空间.。如果我从我的<configuration>元素中删除以下内容,它就能工作:xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

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

终于!!

票数 8
EN

Stack Overflow用户

发布于 2013-11-19 11:28:34

我也有同样的问题。我有一个解决方案,里面有不同的项目。我已经从所有项目中卸载了Microsoft.AspNet.Web.Optimization和WebGrease,并手动删除了所有bin和obj文件夹。

然后,我只在需要这个包的项目中安装了Microsoft.AspNet.Web.Optimization。

此时,我已经从packages文件夹中删除了所有文件。

当我再次打开Visual时,它已经开始从头开始重新安装所有包。

最后,我做了一个区别,这就是结果:

代码语言:javascript
复制
$ git diff App.config
diff --git a/App.config
index ceec0aa..8937482 100644
--- a/App.config
+++ b/App.config
@@ -18,7 +18,7 @@
       </dependentAssembly>
       <dependentAssembly>
         <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
+        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
       </dependentAssembly>
     </assemblyBinding>
   </runtime>


$ git diff Web.config
diff --git a/Web.config b/Web.config
index 7287953..f196254 100644
--- a/Web.config
+++ b/Web.config
@@ -106,7 +106,7 @@
       </dependentAssembly>
       <dependentAssembly>
         <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
+        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
       </dependentAssembly>
     </assemblyBinding>
   </runtime>


$ git diff myproj.csproj
diff --git a/myproj.csproj b/myproj.csproj
index 12987d0..a214bf7 100644
--- a/myproj.csproj
+++ b/myproj.csproj
@@ -24,6 +24,7 @@
     </SccAuxPath>
     <SccProvider>
     </SccProvider>
+    <WebGreaseLibPath>..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -47,8 +48,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Antlr3.Runtime, Version=3.3.1.7705, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processo
-      <HintPath>..\packages\WebGrease.1.3.0\lib\Antlr3.Runtime.dll</HintPath>
+    <Reference Include="Antlr3.Runtime">
+      <HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
     </Reference>
     <Reference Include="Kendo.Mvc">
       <HintPath>..\Dll\kendo\Kendo.Mvc.dll</HintPath>
@@ -84,9 +85,8 @@
       <Private>True</Private>
       <HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
     </Reference>
-    <Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, pr
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.0\lib\net40\System.Web.Optimization.dll</HintPath>
+    <Reference Include="System.Web.Optimization">
+      <HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.2\lib\net40\System.Web.Optimization.dll</HintPath>
     </Reference>
     <Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processor
       <Private>True</Private>
@@ -129,9 +129,8 @@
       <Private>True</Private>
       <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
     </Reference>
-    <Reference Include="WebGrease, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchite
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\packages\WebGrease.1.3.0\lib\WebGrease.dll</HintPath>
+    <Reference Include="WebGrease">
+      <HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>
@@ -760,7 +759,6 @@
     <Content Include="Views\Home\Index.cshtml" />
     <Content Include="Views\Shared\Error.cshtml" />
     <Content Include="Views\Shared\_LoginPartial.cshtml" />
-    <Content Include="Views\Shared\_Layout.cshtml" />
     <Content Include="Views\Web.config" />
   </ItemGroup>
   <ItemGroup>
@@ -800,6 +798,7 @@
       <Generator>RazorGenerator</Generator>
       <LastGenOutput>index1.generated.cs</LastGenOutput>
     </Content>
+    <Content Include="Views\Shared\_Layout.cshtml" />
   </ItemGroup>
   <PropertyGroup>
     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

特别是,App.config和Web.config都有以下区别:

代码语言:javascript
复制
       <dependentAssembly>
         <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
+        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
       </dependentAssembly>
     </assemblyBinding>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16866676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档