无法加载文件或程序集“WebGrease”它的一个依赖。找到的程序集清单定义不匹配程序集引用 [英] Could not load file or assembly 'WebGrease' one of its dependencies. The located assembly's manifest definition does not match the assembly reference

查看:1330
本文介绍了无法加载文件或程序集“WebGrease”它的一个依赖。找到的程序集清单定义不匹配程序集引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想System.Web.Optimization添加到我的ASP.NET Web窗体的解决方案。
我加的Microsoft ASP.NET Web优化框架,通过的NuGet包。它补充Microsoft.Web.Infrastracture和WebGrease(1.5.2)的引用。

I am trying to add System.Web.Optimization to my ASP.NET Web Forms solution. I added Microsoft ASP.NET Web Optimization Framework through NuGet Packages. It added Microsoft.Web.Infrastracture and WebGrease (1.5.2) to the references.

然而,当我运行

<%= System.Web.Optimization.Scripts.Render("~/bundles/js")%>

我得到运行时错误

I get runtime error

Could not load file or assembly 'WebGrease, Version=1.5.1.25624, 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)

我曾尝试加入assemblyBinding到Web.config

I have tried adding assemblyBinding to the Web.Config

<runtime>
  <legacyUnhandledExceptionPolicy enabled="1"/>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.1.25624" newVersion="1.5.2.14234"/>
      </dependentAssembly>
    </assemblyBinding>
</runtime>

但没有任何运气。

But without any luck.

我注意到,我的网站的Web配置包含此行

I noticed that my WebSite's Web config contains this line

 <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

如果我把它替换为

 <configuration>

然后一切正常,我没有得到运行时错误。不幸的是,我需要的xmlns。我的项目的其他组件依赖于它。

Then everything works and I don't get the runtime error. Unfortunately, I need the xmlns. Other components of my project depend on it.

为什么要优化尝试加载时的模式指向V2.0的旧版本?有没有办法迫使它加载最新的或唯一可用的WebGrease.dll?

Why would Optimization try to load an older version when schema is pointing to v2.0? Is there a way to force it to load the latest or the only available WebGrease.dll?

我可以尝试还有什么不改变

What else can I try without changing the

 <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> ?

感谢您的帮助,您可以提供!

Thank you for any help you can provide!

编辑:
1)安装FusionLog结果。也许这将是有益的。

1) Attaching FusionLog Result. Maybe it will be helpful

=== Pre-bind state information ===
LOG: User = [USER]
LOG: DisplayName = WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Projects/PROJECT_NAME/trunk/www.PROJECT_NAME.com/
LOG: Initial PrivatePath = C:\Projects\PROJECT_NAME\trunk\www.PROJECT_NAME.com\bin
Calling assembly : System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\PROJECT_NAME\trunk\www.PROJECT_NAME.com\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35

2)确认,问题是

2) Confirmed, The issue is in

<configuration  xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

不过,我不明白为什么

However, I don't understand why

推荐答案

最后,问题是在&lt;结构的xmlns =htt​​p://schemas.microsoft.com/.NetConfiguration/v2。 0&GT; 。这引起了渲染方法加载错误WebGrease组装。

Finally, the issue was in <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">. It caused the Render method to load wrong WebGrease assembly.

删除的xmlns解决这个问题对我来说。

Removing the xmlns solved the issue for me.

这篇关于无法加载文件或程序集“WebGrease”它的一个依赖。找到的程序集清单定义不匹配程序集引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆