首页 > 解决方案 > 调试:可以在我构建控制台应用程序时加载符号,但不能在我的应用程序附加到进程时加载

问题描述

我想调试附加到进程的应用程序。

我已经有一个在调试模式下构建 dll 的命令。

启动.json:

 {

    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            //"preLaunchTask": "build",
            "program": "${workspaceFolder}/src/N3P.Revit/bin/Debug/net472/N3P.Revit.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/N3P.Revit/bin/Debug/net472",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            //"processId": "29856"
            "processName": "Revit.exe"
        }
    ]
}

任务.json:

{
    "version": "2.0.0",
    "tasks": [
        //{
            // "label": "build",
            // "command": "dotnet", //do nothing
            // "type": "process",
            // "problemMatcher": "$msCompile",
            // "args": [           //do nothing
            //     "--info"]
        //},
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/src/N3P.Revit/N3P.Revit.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "watch",
            "command": "dotnet",
            "type": "process",
            "args": [
                "watch",
                "run",
                "${workspaceFolder}/src/N3P.Revit/N3P.Revit.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
        
    ]
}

项目.deps.json:

{
  "runtimeTarget": {
    "name": ".NETCoreApp,Version=v4.7.2",
    "signature": ""
  },
  "compilationOptions": {},
  "targets": {
    ".NETCoreApp,Version=v4.7.2": {
      "Revit_plug_in/1.0.0": {
        "runtime": {
          "N3P.Revit.dll": {}
        }
      }
    }
  },
  "libraries": {}
}

当我单击 .NET Core 启动(控制台)时:

已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Private.CoreLib.dll”。跳过加载符号。模块已优化,调试器选项“仅我的代码”已启用。已加载“C:\Users\user040\Project\neulandt.n3p.revit\src\N3P.Revit\bin\Debug\net472\N3P.Revit.dll”。已加载符号。程序“[24376] N3P.Revit.dll”已退出,代码为 -532462766 (0xe0434352)

符号已加载,但正如预期的那样,它无法运行,因为它是一个 dll。

当我点击 .Net Core Attach 时:

没有问题,但未加载符号

标签: .netdebuggingvisual-studio-code

解决方案


推荐阅读