C# 程序集 'SomeAssembly,使用 'System.Web.Mvc,版本 = 4.0.0.0,其版本高于引用的程序集 'System.Web.Mvc,版本 3.0.0.0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12117889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 22:08:00  来源:igfitidea点击:

Assembly 'SomeAssembly, uses 'System.Web.Mvc, Version=4.0.0.0, which has a higher version than referenced assembly 'System.Web.Mvc, Version 3.0.0.0

c#asp.net-mvcasp.net-mvc-3visual-studio-2010visual-studio-2012

提问by kyleb

I get the following error below after opening and compiling my VS 2010 .net 4.0 MVC3 project in VS 2012 RTM. How can I fix this without upgrading to MVC4?

在 VS 2012 RTM 中打开并编译我的 VS 2010 .net 4.0 MVC3 项目后,出现以下错误。如何在不升级到 MVC4 的情况下解决此问题?

I have VS 2010 and VS 2012 installed side by side.

我并排安装了 VS 2010 和 VS 2012。

Error 1 Assembly 'SomeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

错误 1 ​​程序集 'SomeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 使用 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 其版本高于引用的程序集'System.Web.Mvc,版本=3.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35'

回答by anit

Go to References, Check the current version of System.web.mvc(I guess it is still pointing to mvc3). Remove them and add references once again, but this time System.Web.Mvc 4.0..! If you are using multiple projects in a single solution then.. For e.g. you have two projects ProjA(MVC4) and ProjB(Still in MVC3), if ProjA is has a reference of ProjB or using ProjB then it most likely to give the above mentioned error. You might have to change MVC versions in both the projects.

转到参考资料,检查 System.web.mvc 的当前版本(我猜它仍然指向 mvc3)。删除它们并再次添加引用,但这次是 System.Web.Mvc 4.0..!如果您在单个解决方案中使用多个项目,那么.. 例如,您有两个项目 ProjA(MVC4)和 ProjB(仍在 MVC3 中),如果 ProjA 有 ProjB 的引用或使用 ProjB,那么它很可能给出上述内容提到的错误。您可能需要更改这两个项目中的 MVC 版本。

回答by Bruno Garcia

Check your web.config. system.web/assemblieshas version 3.0 even though your project references 4.0.

检查您的web.config. system.web/assemblies即使您的项目引用 4.0,也有 3.0 版。

It was the case for me.

我就是这种情况。

回答by cobolstinks

Another thing to check is that you dont have a test project still referencing the mvc3 assembly in the solution. Thats what got me.

要检查的另一件事是您没有仍然引用解决方案中的 mvc3 程序集的测试项目。这就是我的原因。

回答by Scanner

If you are using Visual Studio you can check for updates to your NuGet packages, which will update without the need to go messing around manually with the Web.config. Select tools -> Library Package Manager -> Manage NuGet Packages for Solution. Check you are on the most up-to-date version of MVC by selecting updates along the left hand panel, then in the list of updates look for MVC and click update. Once the update has finished click build and build solution. This was how I solved my issue that I was having between MVC and Fluent Validation NuGet package. And it automatically updates Web.config.

如果您使用的是 Visual Studio,则可以检查 NuGet 包的更新,这些更新无需手动处理 Web.config。选择工具 -> 库包管理器 -> 管理解决方案的 NuGet 包。通过选择左侧面板上的更新来检查您使用的是最新版本的 MVC,然后在更新列表中查找 MVC 并单击更新。更新完成后,单击构建并构建解决方案。这就是我解决我在 MVC 和 Fluent Validation NuGet 包之间遇到的问题的方法。它会自动更新 Web.config。

回答by linds

Using asp.net 4.5 and had a similar problem. Right click on Referencesand go to Manage NuGet Packages. Check to see if there is an update for the package with an outdated version. May ask to overwrite files but that is ok.

使用 asp.net 4.5 并有类似的问题。右键单击References并转到Manage NuGet Packages。检查是否有版本过时的软件包的更新。可能会要求覆盖文件,但没关系。