The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
24,987
Solution 1
- Restart Visual studio
- Remove the assembly reference and re-add it
- Do a clean and re-build
- Try install Microsoft.AspNET.MVC from nuget package manager
Solution 2
in my case it worked only after I run in the Package Manager Console following command
PM> Install-Package Microsoft.AspNet.Mvc
My environment was:
1) Visual Studio 2017
2) Freshly created Angular 4 app
3) MVC 6 as a back end
Related videos on Youtube
Comments
-
davids over 3 years
Whenever I try to compile my VS2015 application, I a long list of errors like:
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
However, as soon as I double click the error to view the file, it opens the file, has a slight delay, then clears ALL the errors.
If I proceed to try and build again, I get the same list of errors and the process repeats itself.
UPDATE I forgot to mention that I have tried:
- following the advice in several other SO questions - to no avail
- ensuring the dlls are set to copy to local
- removing and re-adding references
- deleting dlls from the application and adding them back
- cleaning and rebuilding the application
- restarting the application and my computer
What would cause this? How do I eliminate it?
-
Ian about 8 yearsThis is perhaps due to the heavy tasks which VS2015 do in background all the time and it cannot handle the big scope of your project. Try to reduce the amount of files in the project if there are too many.
-
ProgrammingDude about 8 yearsHave you tried restarting visual studio? Have you moved any files around from one folder to another?
-
EdSF about 8 yearsIn that long list, try to scroll lower to things that look more like "real errors" (syntax, etc.). Also you may have updated a package in one project and not in related projects (mismatch). If all else fails, and the errors simply don't make sense , push that nuke button and simply restart VS (yes, I meant that, it's not a joke)...Hth.
-
Martin Dawson about 8 yearsYour web.config references might be incorrect. Re downloading nuget packages may fix
-
Manish over 7 yearsUnbelievable, restarting Visual Studio was indeed the answer. Had been wrestling with this for over 3 hours. Visual Studio Community 2015 update 3 with .NET framework 4.6.01055. System.Web.Mvc version is 5.2.3
-
davids about 8 yearsI have other MVC solutions that continue to work just fine, so I don't think it is an issue with MVC. I have tried all the others previously.
-
Nick about 8 yearsIt's usually not a issue that affects all MVC applications, rather your solution file has somehow had a path or config messed up that has broken the project. If you have tried these steps including the re-install of MVC from nuget then i am our of ideas sorry.
-
Harvey Darvey over 6 yearsWorks for me, I had to force remove nuget package for MVC, Razor, and WebPages and reinstall them. After that it worked. For me it was not an issue with the machine, several machines had that issue.
-
Nirav Vasoya almost 5 yearsI am getting the same error in my project, structure is, 1 project i have edmx and getting reference in another one Web project. is error related to the structure? or anything else? i have follow the same step which you mention but still facing the same issue. @Nick