Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 943
Sam Avatar asked Mar 12 '17 01:03

Sam


People also ask

How do I fix error cs0246?

There are two solutions to this error. The first is to correct the name of the namespace to match one that already exists. The second is to fix the custom namespace that was created.

How do I fix cs0234?

To fix this error, simply update the example . csproj file to use a previous System. CommandLine version. Note that this package is only used to parse the options for the example.

How to fix the type or namespace could not be found?

Solution 1 That may be it's in a different project in the current solution, in a external DLL, or just in a different namespace in another file in the current project. Start by hovering the mouse over the error, and open the drop down that appears. If it has an "include" option, click that, and it should fix it.


1 Answers

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

like image 120
Swinkaran Avatar answered Sep 18 '22 18:09

Swinkaran