c# - 无法在 Visual Studio Code 上启动 C# 调试器

标签 c# debugging visual-studio-code

场景:
我正在尝试在 Sabayon Linux 下的 Visual Studio Code 上调试 asp.net 核心项目。当我按 F5 时,我收到以下消息:

Run 'Debug: Download .NET Core Debugger' in the Command Palette or open a .NET project directory to download the .NET Core Debugger

打开命令面板并选择“调试:下载 .NET Core 调试器”什么都不做。

软件版本:
Sabayon Linux 16.07
dotnet --version 1.0.0-preview2-003121
Visual Studio Code 1.4.0
VSC 1.3 的 C# 扩展

启动.json

{
"version": "0.2.0",
"configurations": [
    {
        "name": ".NET Core Launch (console)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/myproject.dll",
        "args": [],
        "cwd": "${workspaceRoot}",
        "stopAtEntry": false,
        "externalConsole": false
    },
    {
        "name": ".NET Core Launch (web)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
        "args": [],
        "cwd": "${workspaceRoot}",
        "stopAtEntry": false,
        "launchBrowser": {
            "enabled": true,
            "args": "${auto-detect-url}",
            "windows": {
                "command": "cmd.exe",
                "args": "/C start ${auto-detect-url}"
            },
            "osx": {
                "command": "open"
            },
            "linux": {
                "command": "xdg-open"
            }
        },
        "env": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "sourceFileMap": {
            "/Views": "${workspaceRoot}/Views"
        }
    },
    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command.pickProcess}"
    }
]

最佳答案

BugFinder的评论帮助我在 Debian 9 下的 Visual Studio Code 上解决了同样的问题:

  1. 删除位于 ~/.vscode/extensions/ms-vscode.csharp- 的整个 csharp 扩展目录,然后重新安装最新版本的 C# 扩展
  2. 在输出面板(查看 -> 切换输出)中查看调试器安装状态并选择“Razor 日志”选项
  3. 修复那里发现的所有可能问题(对我来说,缺少“libunwind8”依赖项,实际修复是运行“sudo apt-get install libunwind8”)
  4. 重启 Visual Studio Code

关于c# - 无法在 Visual Studio Code 上启动 C# 调试器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38991315/

相关文章:

c# - 在 View 或 Controller 之外的 ASP.NET MVC 中生成 url

android - 使用 VMWare/VirtualBox 之类的虚拟机进行调试?

git - Visual Studio Code : Git diff over git gutter indicator

c# - 将 wpf 元素树序列化为 Xaml 的最佳方法?

c# - 如何制作折线图从0 X轴开始

c++ - 错误代码 C2451 无法运行基本程序

linux - 父 shell 终止后恢复 gdb session

bash - VS Code - wsl 服务器意外关闭

visual-studio-code - 如何让vscode自动使用cmake include路径

c# System.OutOfMemoryException 我该如何解决?