我把一个项目从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.NETASP.NET Web Pagesv1.0AssembliesSystem.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:UsersOEMdocumentsvisual studio 2012ProjectsDabTrialpackagesMicrosoft.AspNet.WebPages.2.0.30506.0libnet40System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
等等。
当我查看参考文献时,它们都是后来的版本,以及web。Config指的是更新后的版本。当我通过公钥令牌(在windows资源管理器中)搜索整个解决方案目录时,我没有找到引用早期版本的XML类型文件。
显然文件的路径是不同的,但我找不到编译器被定向到早期.dll文件的路径。
项目构建和运行良好,但我认为编译器建议这些更改是有原因的。谢谢你的帮助。
您的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>
您还可以尝试在包管理器控制台
中运行以下命令Update-Package -Reinstall
对于这个命令,你必须至少有版本2.1的nuget,但是如果你已经更新了。net,它会更新你的包并重新定位它们。你可以查看这篇文章了解更多信息。
从。net 4.0到4.5的重定向解决方案-如何重定向NuGet包?
我也遇到过这样的问题。我只做了两件事:
- 更新了System.Web.Mvc和所有依赖项到最新版本(5.2.3)
- 重建所有解决方案(我使用"解决方案 -> 清洁解决方案",然后"解决方案 -> 构建解决方案")
尝试在项目文件中设置AutoGenerateBindingRedirects
为true