14
votes

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'

5
stackoverflow.com/questions/5163773... All basically the same problem.Robert Harvey
Yea I tried these things and now it compiles but I get this below..I don't see any references to mvc3 stuff in .config files or csproj files. BUt I will look again. Any ideas [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection.kyleb

5 Answers

26
votes

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

12
votes

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

It was the case for me.

8
votes

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.

2
votes

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.

0
votes

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.