C# - VS 代码 - 启动 :program . .. 不存在

标签 c# .net visual-studio-code omnisharp

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

enter image description here

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

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

收件人:

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

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

enter image description here

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

先卸载 VS Code,再卸载 .NET Core 2.1,从 %USER%\.vscode\删除 VS Code 扩展文件夹,重新安装 VS Code,然后卸载 .NET Core 2.1,再安装 C# 扩展(C# for Visual Studio代码(由 OmniSharp 提供支持))。

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

这是 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"
    }
]
}

最佳答案

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

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

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

希望对你有用!

关于C# - VS 代码 - 启动 :program . .. 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52391861/

相关文章:

c# - WPF:如何将 Unicode 字符转移到共享资源中?

c# - Initializer.Seed() 在 context.SaveChanges() 上抛出异常

c# - Winforms绑定(bind)问题

npm - Visual Studio Code (Windows) 未检测到全局 NPM 模块

javascript - ES 模块和 jsconfig.json : Error [ERR_MODULE_NOT_FOUND]

c# - 将方法分配给动态创建的控件

c# - .NET:独立存储异常

c# - DBNull怎么可能不等于DBNull

c# - 根据用户输入更改标签颜色

java - 如何在VS Code中设置JAVA环境变量