系统找不到 Visual Studio 2017 ASP.NET Core 项目 [英] System could not be found Visual Studio 2017 ASP.NET Core project

查看:37
本文介绍了系统找不到 Visual Studio 2017 ASP.NET Core 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了新发布的 Visual Studio 2017 版本,并启动了一个针对 .NET Core 的全新 ASP.NET Core 项目.

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

开箱即用,我得到了

找不到类型或命名空间名称System"(您是缺少 using 指令或程序集引用?)

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?

此外,看起来 NuGet 包也存在问题:

Also, looks like there are problems with NuGet packages as well:

我也通过命令行在项目上尝试过dotnet restore,得到如下错误:

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

附言令人沮丧的是,在最新版本的 Visual Studio 2017 中的新项目中出现错误!

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

更新:SDK 版本是 v 1.0.1——见下文:

UPDATE: SDK version is v 1.0.1 -- see below:

更新2:这很奇怪.看起来原来的问题是由于 NuGet 包源指向 Visual Studio 2015 文件夹下的文件夹.我取消选中它,只留下 nuget.org.有了这个,我的项目似乎已经恢复了所有的包,当我开始这个项目时,它加载了标准的 ASP.NET 页面.但是如果我打开 startup.cs 文件,我会在整个地方看到红色波浪线,但是如果我运行该项目,它工作正常.这里发生了什么?

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?

更新 3:我关闭了项目和 VS 2017.然后我重新启动了 VS 2017 并打开了项目,现在它似乎没问题.而且我没有引用 .NETStandard 库 1.6.1,现在似乎一切正常.

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.

推荐答案

今天遇到了同样的问题.我有一个不再存在的旧 nuget 源.所以我进入了工具 > Nuget Packet Manager 并取消了错误的检查.点击确定",然后重建项目,现在效果很好.您似乎偶然发现了它,但也想验证它是否解决了我的问题,并且确实如此.

Came across the same issue today. I had an old nuget source that no longer existed. So I went into Tools > Nuget Packet Manager and un-checked the wrong one. Hit "Ok", and then rebuilt the project, and it works great now. It seems like you stumbled onto it, but also wanted to verify that it fixed my issue, and it does.

这篇关于系统找不到 Visual Studio 2017 ASP.NET Core 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆