从现在开始,我一直在面对下一个问题。
我从 asp.net core 2.0 和 vs 代码开始。我已经通过 omnisharp 安装了 VS Code 1.17.2、dotnet sdk 2.0 和 C# extension 1.13.0。
我创建了一个运行 dotnet new mvc
的 mvc 项目。当我打开 vs 代码时,我在 .cs 文件中遇到了很多错误。
我能够毫无问题地构建和运行应用程序。
IntelliSense 和调试也有效。 当我看到错误选项卡时,我注意到下一个错误以及许多其他错误:
The type 'TargetFrameworkAttribute' exists in both 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
我猜我的环境有问题,但我不知道是什么。任何想法表示赞赏。
最佳答案
看起来是与 Omnisharp 如何使用本地安装的 Visual Studio 2017 中的 MSBuild 相关的错误。如果您的 VS 安装已过期,您可能会看到此错误。
该问题据说已在 1.13.1 中修复发布 VS Code 的 Omnisharp 扩展。
票证提到 Visual Studio 2017 RTM 是罪魁祸首,但据传闻,我在 15.2 上遇到了同样的问题。
请在此处查看错误票以了解更多详细信息:github.com/OmniSharp/omnisharp-vscode/issues/1855
工单解决方案:
- Update VS 2017 - this is generally worthwhile anyway as there have been 4 updates since RTM.
- Download and use a version of OmniSharp with the a fix that will cause OmniSharp not to use VS 2017 RTM. You can follow the instructions here to do that.
- Install the last release of C# for VS Code (1.12.1) and change the "extensions.autoUpdate" to false.
关于c# - vs代码的omnisharp扩展错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47211567/