当尝试在C#DotNet Core MVC应用程序上使用Visual Studio Code时,我在使Visual Studio代码工作时遇到了很多麻烦.它无法找到与C#相关的任何内容,甚至标记为"使用系统"; 无效,说它找不到它.
但是,当我运行dotnet build时,它会成功,没有警告或错误,项目就会运行.
我的project.json:
{ "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0", "type": "platform" }, "Microsoft.EntityFrameworkCore.Sqlite": "1.1.0", "Microsoft.EntityFrameworkCore.Design": { "version": "1.1.0", "type": "build" }, "Microsoft.AspNetCore.Mvc": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.Extensions.Logging.Debug": "1.1.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", "Microsoft.AspNetCore.StaticFiles": "1.1.0" }, "frameworks": { "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" } }, "imports": "dnxcore50" } } }
有任何想法吗?我真的用这个把头发拉了出来.
有时,Visual Studio Code的C#(由OmniSharp提供支持)会变得混乱.
尝试重新启动OmniSharp.这有两种方式:
关闭并重新打开Visual Studio代码,或
打开Command Pallet并键入Restart Omnisharp
.
如果我们从命令行而不是从Visual Studio Code中恢复依赖关系,OmniSharp往往会变得混乱.