简体   繁体   中英

Upgrading solution from MVC 3.x to MVC 5.2.3: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'

I have a solution that was originals built using VS 2010 and MVC 3.something. I am now using VS 2015 and MVC 5.2.3. I deleted the old reference to MVC3 and changed it to the 5.2.3 dll. Now, whenever I try to build the solution, I receive multiple instances of this error:

Error   CS0234  The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)  

The error happens in each file (class) when I try to use System.Web.MVC:

using System.Web.Mvc;

The reference DOES exist. The odd thing is, if I remove this line in a given file, and replace it with the exact same thing, the error for that file will temporarily vanish, but will then come back at some seemingly random point in the future when I build again.

Based on some other threads of a similar nature, here's a couple things I have tried:

  • Create a new project in VS2015 using MVC5, then copy the Web Config files from the new solution into the existing solution. Both in the root, and in the Views folder
  • Made sure Copy Local on the ref to System.Web.MVC is set to True

Any other suggestions?

Is there more than one project in the solution? It's possible that one of the other projects is referencing an older version of MVC.

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