visual studio express 2012 app.config重映射程序集

时间:2013-06-06 00:23:28

标签: visual-studio-2012 assembly-resolution

我刚才将一个项目从MVC 3移到了MVC 4。

当我建立时,我收到了消息

1>  No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0 ..." and , Version=2.0.0.0
1>  Consider app.config remapping of assembly "System.Web.WebPages ..." from Version "1.0.0.0" to Version "2.0.0.0"  to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Web.WebPages.Razorfrom Version "1.0.0.0" [c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\OEM\documents\visual studio 2012\Projects\DabTrial\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.

等等。

当我查看引用时,它们都是更高版本,而web.config仅引用更​​高版本。当我通过公钥令牌(在Windows资源管理器中)搜索整个解决方案目录时,我找不到引用早期版本的XML类型文件。

显然文件的路径不同,但我无法找到编译器定向到早期.dll文件路径的位置。

项目构建并运行良好,但我认为编译器建议这些更改是有原因的。谢谢你的帮助。

3 个答案:

答案 0 :(得分:12)

您的nuget依赖项可能引用了MVC3版本。您可以尝试将以下内容放入Web配置中以强制使用MVC4版本:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
</runtime>

您还可以尝试在Package Manager Console

中运行以下内容
Update-Package -Reinstall

此命令必须至少具有2.1版本的nuget,但如果您更新了.NET,它将更新您的软件包并重新定位它们。您可以查看此帖子以获取更多信息。

Retargeting solution from .Net 4.0 to 4.5 - how to retarget the NuGet packages?

答案 1 :(得分:0)

我也遇到过这样的问题。我做了两件事:

  • 更新了System.Web.Mvc以及所有依赖关系到最后一个版本(5.2.3)
  • 重建所有解决方案(我使用“解决方案 - &gt; 清洁解决方案”,然后“解决方案 - &gt; 构建解决方案“)

答案 2 :(得分:0)

尝试在项目文件中将 AutoGenerateBindingRedirects 设置为 true