简体   繁体   中英

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

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?

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

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'

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

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

It was the case for me.

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 eg 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.

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.

Using asp.net 4.5 and had a similar problem. Right click on References and 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM