【问题标题】:Can't get the debugger working in Visual Studio Code?无法让调试器在 Visual Studio Code 中工作?
【发布时间】:2017-02-27 16:17:44
【问题描述】:

所以我一直在 Visual Studio Code 中开发一个项目 C# 项目,并且需要使用调试功能。但是,当我运行调试器时,我收到以下消息:

--------------------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (clrdbg) with Visual Studio
Code, Visual Studio or Visual Studio for Mac software to help you develop and
test your applications.
--------------------------------------------------------------------------------
The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found.

  - Check application dependencies and target a framework version installed at:

      C:\Program Files\dotnet\shared\Microsoft.NETCore.App

  - The following versions are installed:

      1.1.0

  - Alternatively, install the framework version '1.0.1'.

The program 'c:\Projects\App1\bin\Debug\netcoreapp1.0\App1.dll' has exited with code -2147450749 (0x80008083).

我最初对该消息的理解是我需要更改 project.json 依赖文件,以便显示 Microsoft.NETCore.App 版本的行从 1.0.1 更新为 1.1.0。然而,这似乎没有任何区别。我试过用谷歌搜索这条消息,但并没有真正理解很多讨论。有人可以为我指出正确的方向吗?

如果我可以提供任何对您有帮助的信息,请告诉我。

目前我的project.json是这样的:

{
"version": "1.1.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
 "frameworks": {
 "netcoreapp1.1": {
  "dependencies": {
    "Microsoft.NETCore.App": {
      //"type": "platform", //remove this line if trying to build a native app via runtime section
      "version": "1.1.0"
    }

  },
  "imports": "dnxcore50"
  }
},
"runtimes": { //this section allows you to specify runtime for native build output, note these will not generate unless type:"platform" is commented out in dependancies
    "win10-x64": {},
    "osx.10.11-x64": {}
  }
}

【问题讨论】:

    标签: c# visual-studio-code


    【解决方案1】:

    您的应用需要 1.0.1 版本的 .NET Core,而您实际上运行的是 1.1.0 版本。我猜你在 Visual Studio 2015 中做了一个项目,然后尝试在 Visual Studio Code 中调试它?

    如果是这样,将project.json中的版本更改为1.1.0,dotnet restore,再次构建并运行。

    Visual Studio 2015 使用版本为 1.0.1 的 Toolkit,而 .NET Core CLI 是 1.1.0,因此请将您的项目依赖项更新为 1.1.0 并恢复

    【讨论】:

    • 这是可能的,是其他人构建了项目模板,我相信他们使用的是 Visual Studio。很抱歉很密集,但是应该更改哪些依赖项?我尝试在 frameworks > dependencies > Microsoft.NETCore.App 下更改版本号,然后恢复项目,我仍然收到相同的消息。
    • @jamessct 检查 project.json 文件。应该有几个对 .NET Core 版本的引用。
    • @jamessct 也可能有一个 global.json 文件,其中有一个“sdk”版本,也可以更改。
    • @jamessct 在 project.json 中,在 dependencies > Microsoft.NETCore.App, frameworks > netcoreapp 1.0 -> 1.1 下更改版本。
    • 我已将我的 project.json 添加到我所做的更改的 OP 中。我还在 project.lock.json 中搜索了“NETCore.APP”,并将所有对 1.1.0 的引用更改为 dotnet restore,但无济于事 - 仍然得到完全相同的消息。你能看到我可能错过的任何东西吗?
    猜你喜欢
    • 2019-12-30
    • 2022-09-23
    • 1970-01-01
    • 2017-12-18
    • 1970-01-01
    • 1970-01-01
    • 2022-06-24
    • 1970-01-01
    • 2016-12-23
    相关资源
    最近更新 更多