System could not be found Visual Studio 2017 ASP.NET Core project

Sam picture Sam · Mar 12, 2017 · Viewed 41.2k times · Source

I've installed the newly released version of Visual Studio 2017 and started a fresh ASP.NET Core project targeting .NET Core.

Out of the box, I'm getting the

The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

error. Any idea what's causing this and how to fix it?

enter image description here

Also, looks like there are problems with NuGet packages as well: enter image description here

I also tried dotnet restore on the project through the command line and got the following error: enter image description here

P.S. Kind of disheartening that you get an error in a fresh new project in the latest version of Visual Studio 2017!

UPDATE: SDK version is v 1.0.1 -- see below: enter image description here

UPDATE 2: This is very strange. Looks like the original problem was due to NuGet package source pointing to a folder under Visual Studio 2015 folder. I unchecked it and left only nuget.org. With that my project seemed to have restored all the packages and when I started the project it loads up the standard ASP.NET page. But if I open startup.cs file, I get red squigglies all over the place but if I run the project, it works fine. What's going on here? enter image description here

UPDATE 3: I closed the project and VS 2017. I then restarted VS 2017 and opened the project and now it seems to be fine. And I'm not referencing the .NETStandard library 1.6.1 and everything seems to be working fine now.

Answer

Swinkaran picture Swinkaran · Apr 29, 2017

I had the same issue in my Visual studio 2017 .Net Core application. I closed the Visual studio and re-open fixed everything.