【问题标题】:How to get rid of the MSB3247 (assembly version conflict) warning in an MVC3 app?如何摆脱 MVC3 应用程序中的 MSB3247(程序集版本冲突)警告?
【发布时间】:2013-11-10 01:12:54
【问题描述】:

我有一个 MVC3 应用程序,它依赖于引用 MVC1 的 DotNetOpenAuth 库。当我安装 DotNetOpenAuth NuGet 包时,它向我的 web.config 添加了程序集绑定重定向。我取消了它的注释,但没有任何改变。

经过一番搜索,我发现这通常是一个拼写错误的原因,但我怀疑这是否适用于我,我检查了至少十几次配置是否有拼写错误。

我将 web.config 精简为以下内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

在构建过程中,我收到以下警告:

Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to solve conflict and get rid of warning.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.

我在我的 web.config 中尝试了很多不同的组合(例如,添加culture="neutral" 属性),但都没有成功,而且我的想法已经用完了。有什么建议吗?

更新 我的 ~/Views/web.config 是here

【问题讨论】:

  • 我们也可以看看你的~/Views/web.config 吗?请记住,&lt;pages&gt; 引用了 System.Web.Mvc
  • @BradChristie 当然,我在问题中添加了一个 pastebin 链接
  • NuGet 包在您引入时是否带入/包含 System.Web.Mvc.dll?可能是您的项目部署了两个副本并导致问题 - stackoverflow.com/questions/17806/…(第二个答案)
  • @Tommy 是的,包引用了 MVC1,这是问题的根源,因为我的应用程序引用了 MVC3。我想使用官方包(我知道用 MVC3 参考重建它可以解决这个问题)。我理解这个警告,我理解为什么我会得到它,我不明白的是:我做了它暗示要做的事情,但我仍然在构建过程中得到它。为什么?

标签: c# asp.net-mvc-3 dotnetopenauth


【解决方案1】:

在类似的情况下,对于 .NET Framework 4.5 项目,Visual Studio 2013 最近将我指向了这篇 MSDN 文章:

How to: Enable and Disable Automatic Binding Redirection

顺便说一句:它对我们有用,至少在从 VS 运行构建时。相反,从命令行脚本运行构建时它没有任何效果。

【讨论】:

  • 感谢您的提示,下次我必须再次触摸那个该死的项目时,我会尝试一下(=希望永远不会)。
猜你喜欢
  • 1970-01-01
  • 2011-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-24
  • 2020-06-01
  • 1970-01-01
相关资源
最近更新 更多