0

I'm trying to get step through debugging support for a C# .net project that I'm building and running on a Linux machine. Since Visual Studio doesn't run natively on Linux, I installed it on my windows virtual box and am trying to use remote debugging through an SSH tunnel to attach to the Linux process on my host OS.

I feel like I'm very close. I can connect and attach to the process successfully, but when I try to put breakpoints in the code I get a warning saying that the module hasn't been loaded. I followed a troubleshooting guide and verified on the Debug -> Windows -> Modules screen that my application module is not there.

For troubleshooting purposes I created a simple default console app on my Linux machine using VS code. These are the files:

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

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Console.ReadKey();
int x = 52;
int y = 3;
int result = x * y;
Console.WriteLine($"calculation {result}");

I tried running the application in various ways but the result was always the same. For demonstration purposes I'll use the approach in this guide and run with dotnet TestApp/bin/Debug/net6.0/TestApp.dll in the VS code terminal. I get my expected output Hello, World! followed by a newline where the program waits for input.

I switch to my virtual box running windows and Visual studio and load the same project from the shared folder. I attach the debugger to my host OS using SSH connection type and target the process with name 'dotnet' and title 'dotnet TestApp/bin/Debug/net6.0/TestApp.dll'. It's worth noting that there a bunch of other dotnet processes but only this one seems to contain the word TestApp.

I set a breakpoint in visual studio after the Console.ReadKey(); line and get a warning telling me the breakpoint won't be hit because the module hasn't been loaded. I check the loaded modules and see a bunch of c libraries but TestApp.dll isn't there.

When I press enter in the VS code terminal on Linux it prints the calculation result and exits without the breakpoint in Visual Studio ever getting triggered.

1 Answer 1

0

I use WSL to debug on Ubuntu from my Visual Studio, installed on Windows machine. Several months have passed since I have done this for the first time, but it was unexpectedly easy. As far as I remember I selected the dropdown for WSL from the VS, displayed here. After that it prompted me what I want to install and I just followed the prompts (with latest Visual Studio 2022).

Sign up to request clarification or add additional context in comments.

2 Comments

I'm aware of WSL, but the application I ultimately want to set this up for is a game that published its source code to assist modders. So running it through WSL on a VM will kill performance (I can't run windows on my actual hardware these days, it blue screens even during a clean install). I can probably live with it if it's only when I need the debugger, but the setup I'm going for ought to work.
I was wrong, the setup I'm going for can't work because GDB does not support C#. Marking your reply as answer because it seems to be the best option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.