9

我正在尝试在 VS Code 中调试一个简单的“Hello world”应用程序,但是,当我按 Ctrl + F5 时,它给了我以下错误:

在此处输入图像描述

如果我手动更改 launch.json 中的路径:

${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll

至:

"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"

它确实有效,但是在没有我手动输入路径的情况下它可以正常工作之前。另外,我注意到 VS Code 不再像以前那样要求重建资产:

在此处输入图像描述

到目前为止,我已经尝试了以下方法:

卸载 VS Code,然后是 .NET Core 2.1,从 %USER%\.vscode\ 中删除 VS Code 扩展文件夹,重新安装 VS Code,然后是 .NET Core 2.1,然后是 C# 扩展(C# for Visual Studio Code(供电由 OmniSharp))。

当 VS Code 启动时,它确实成功下载了“OmniSharp”包,但是当我打开 C# 文件时,仍然没有提示重建资产。调试给出了与以前相同的问题。

这是launch.json:

"version": "0.2.0",
"configurations": [
    {
        "name": ".NET Core Launch (console)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
        "args": [],
        "cwd": "${workspaceFolder}",
        "console": "internalConsole",
        "stopAtEntry": false,
        "internalConsoleOptions": "openOnSessionStart"
    }

还有tasks.json:

    "version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "command": "dotnet build",
        "type": "shell",
        "group": "build",
        "presentation": {
            "reveal": "silent"
        },
        "problemMatcher": "$msCompile"
    }
]
}
4

9 回答 9

11

我找到了一个适合我的解决方案。我的 VS Code 给了我同样的错误信息,我修复它的方法是:

- Press the combination Ctrl + Shift + P
- Restart Omnisharp
- Then it asks if you want to add missing files for build.
- Click Yes.

在此之后,我能够调试我的应用程序。

希望这对你有用!

于 2019-01-09T12:09:17.453 回答
2

访问项目文件夹中的\bin\Debug\netcoreapp3.1(在 VS 中打开)

转到 VS 中的 launch.json 文件:

替换:“程序”:“${workspaceFolder}/bin/Debug//.dll”,

:“程序”:“${workspaceFolder}/bin/Debug/netcoreapp3.1/.dll CSharp”,

在可能的情况下,该项目被称为CSharp. 小心。

于 2020-08-04T16:18:57.143 回答
2

我有同样的错误。调试器正在寻找 .dll 文件,${workspaceFolder}/bin/Debug/netcoreapp3.1/myApp.dll但该文件位于${workspaceFolder}/bin/MCD/Debug/netcoreapp3.1/tradeAppl.dll

将launch.json文件更改为读取后

...
"program": "${workspaceFolder}/bin/MCD/Debug/netcoreapp3.1/tradeAppl.dll",
...

我能够毫无问题地调试应用程序。

于 2020-09-05T02:33:13.870 回答
0

因为你有 :".dll" 用“<”和“>”标记,这意味着你给它一个值。最简单的方法是在 VSCode 中打开项目并使用 find&replace 将:替换为您的项目名称,我相信它:根据 .dll 名称“测试”

于 2018-09-18T17:37:35.567 回答
0

我切换到 MS Visual Studio,因为我没有找到任何其他解决方案。

于 2018-11-06T21:41:39.180 回答
0

像这样Gist配置你的 Launch.json

并且不需要 Tasks.json ,您可以按 F5 自行构建或配置它,当您按 F5 时,应该在默认 shell 中运行哪个命令

于 2018-12-02T07:56:36.813 回答
0
// "program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
   "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/csharp_multi_threads.dll",

您需要根据提示更改程序值

于 2020-05-09T01:59:49.853 回答
0

-右键单击项目名称并单击在资源管理器中显示 -在文件夹名称后复制资源管理器中的 URL 例如我的文件夹地址是 D:\IOT\Projects\LWSIOT_WebApiWM2\LWSIOT_WebApiWM2\LWSIOT_WebApiWM2\bin\Debug\netcoreapp3.1\LWSIOT_WebApiWM2.dll并在 Launch.json 中: ${workspaceFolder}/LWSIOT_WebApiWM2/LWSIOT_WebApiWM2/bin/Debug/netcoreapp3.1/LWSIOT_WebApiWM2.dll -在 Launch.json 中粘贴“程序”:“<Your_Address>” -单击调试并确定

于 2021-01-09T07:00:56.853 回答
0

在 launch.json 中,替换:

"程序": "${workspaceFolder}/Api/bin/Debug/netcoreapp3.1/Api.dll",

和:

“程序”:“${workspaceFolder}/Api/bin/linux/Debug/netcoreapp3.1/Api.dll”

由于我在 Linux 机器上运行代码,所以我应该提供 Linux 文件夹的路径

于 2021-03-12T04:21:27.253 回答