You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows虚拟机远程调试Linux上.NET代码:模块未加载致断点失效

远程调试Linux上的.NET进程:模块未加载导致断点无法触发

问题概述

我在Linux机器上构建并运行C# .NET项目,需要实现单步调试支持。由于Visual Studio无法在Linux原生运行,我在Windows虚拟机中安装了Visual Studio,尝试通过SSH隧道远程调试宿主Linux系统上的进程。目前已成功连接并附加到目标进程,但设置断点时收到提示:模块未加载。查看Debug -> Windows -> Modules窗口,确认应用模块确实未被加载。

用于排查的测试项目

为定位问题,我在Linux上用VS Code创建了一个简单的默认控制台应用,文件内容如下:

test-app.sln

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{5021DE1D-9E17-4375-B5CA-0556BB75AA08}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {5021DE1D-9E17-4375-B5CA-0556BB75AA08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {5021DE1D-9E17-4375-B5CA-0556BB75AA08}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {5021DE1D-9E17-4375-B5CA-0556BB75AA08}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {5021DE1D-9E17-4375-B5CA-0556BB75AA08}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
EndGlobal

TestApp/TestApp.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

TestApp/Program.cs

Console.WriteLine("Hello, World!");
Console.ReadKey();
int x = 52;
int y = 3;
int result = x * y;
Console.WriteLine($"calculation {result}");

操作流程与异常现象

  • 在Linux的VS Code终端执行命令:dotnet TestApp/bin/Debug/net6.0/TestApp.dll,程序正常输出Hello, World!并等待用户输入。
  • 切换到Windows虚拟机,在Visual Studio中从共享文件夹加载该项目,通过SSH连接类型附加到宿主Linux系统上标题为dotnet TestApp/bin/Debug/net6.0/TestApp.dll的dotnet进程(其他dotnet进程不含TestApp标识)。
  • 在Visual Studio中为Console.ReadKey();行后的代码设置断点,收到警告:断点无法命中,因为模块未加载。查看已加载模块列表,仅显示部分C库,TestApp.dll不在其中。
  • 在Linux终端按下回车后,程序输出计算结果并退出,Visual Studio中的断点始终未触发。

内容的提问来源于stack exchange,提问作者Ghost314

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 01:20:56