Assembly 'SomeAssembly, uses 'System.Web.M

2020-03-09 08:22发布

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条回答
▲ chillily
2楼-- · 2020-03-09 09:02

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.

查看更多
孤傲高冷的网名
3楼-- · 2020-03-09 09:05

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

It was the case for me.

查看更多
爷、活的狠高调
4楼-- · 2020-03-09 09:08

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

查看更多
Explosion°爆炸
5楼-- · 2020-03-09 09:08

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.

查看更多
可以哭但决不认输i
6楼-- · 2020-03-09 09:23

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.

查看更多
登录 后发表回答