c# - vs代码的omnisharp扩展错误

标签 c# visual-studio-code .net-core asp.net-core-2.0

从现在开始,我一直在面对下一个问题。 我从 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 文件中遇到了很多错误。 enter image description here

我能够毫无问题地构建和运行应用程序。

enter image description here

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'

enter image description here

我猜我的环境有问题,但我不知道是什么。任何想法表示赞赏。

最佳答案

看起来是与 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

工单解决方案:

  1. Update VS 2017 - this is generally worthwhile anyway as there have been 4 updates since RTM.
  2. 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.
  3. 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/

相关文章:

c# - 创下本地高分?

C# 关键字类似于 "this"但对于当前类类型?

c# - ShouldSerialize*() 与 *指定的条件序列化模式

node.js - Monorepo 中 NestJs dockerized 应用程序的 VS 代码调试

c# - .NET Core 2.1 控制台应用程序中的 IHttpClientFactory 引用 System.Net.Http

asp.net-core - Visual Studio 15 上不存在 ASP.NET Core Web 应用程序模板

c# - SSIS 脚本组件 : Microsoft. SqlServer.Dts.Pipeline.BlobColumn

c# - 如何在 Mac OS X 上的 VSCode 项目中包含 'System.Runtime.Serialization.Json' 命名空间?

visual-studio-code - Vscode 自动完成显示是否仅按下空格键

c# - 如何为 Swagger UI 定义参数的默认值?