Mono: Is Remote Debugging Possible with Monodevelop

mono : Is remote debugging possible with monodevelop?

This could actually be done with the Soft Debugger.

Is MonoDevelop remote debugging works on Windows

Prooved! It works. The problem was in unhandled exception thrown by VirtualMachineManager.ListenInternal(2) method in Mono.Debugger.Soft. More details here - Can't use Mono Soft Debugger Remote Debugging because 'debugger-agent: DWP handshake failed' error

Debugging mono applications directly on ARM target

Monodevelop can debug remote targets if you have networking going. before launching monodevelop you need to set the environment variable:

MONODEVELOP_SDB_TEST=1

Then when you launch MD you'll have "Custom Mono Soft Debugger" as a "Debug With" option.

On the remote host, launch your debug target like so (I'm assuming it has a shell):

mono --debug \
--debugger-agent=transport=dt_socket,address=0.0.0.0:12345,server=y \
myprogram.exe

In Mono develop, set your breakpoints and then input the IP address of your target machine and the port number above and click Connect. That should break into the debugger remotely.

Linux .NET remote debugging from Visual Studio

I have finally found a good way to perform remote debugging of C# code running on my Raspberry Pi. I have switched from Mono to .NET Core and can now use Visual Studio to debug code running on the Raspberry Pi almost as easy as when running on my development machine.

The following steps were tested using Windows 10 version 1909, Visual Studio 2019 version 16.4.3, Raspbian Buster Lite version 2020-02-13 and a Raspberry Pi 2 Model B. .NET Core requires an ARMv7 CPU, so it will not run on Raspberry Pi 1 and Zero.

  1. Go to https://dotnet.microsoft.com/download/dotnet-core and select .NET Core 3.1 (or later). Click the link for Linux ARM32 runtime binaries and copy the direct link displayed on the next page. (Do not right-click the ARM32 link and select copy link address, as you will end up with a webpage if you download that link.)

    .NET Core download website

  2. Open a SSH session to the Raspberry Pi, download and install the binaries:

    ssh pi@192.168.0.xxx
    wget https://download.visualstudio.microsoft.com/download/pr/c11e9248-404f-4e5b-bd99-175079419d6f/83902a43e06f9fb4e45a4c6a6d5afc0b/dotnet-runtime-3.1.3-linux-arm.tar.gz
    sudo mkdir /opt/dotnet
    sudo tar zxf dotnet-runtime-3.1.3-linux-arm.tar.gz -C /opt/dotnet
    sudo ln -s /opt/dotnet/dotnet /usr/bin/dotnet
  3. Add the following line to ~/.bashrc, logout and login again to activate:

    export DOTNET_ROOT=/opt/dotnet
  4. Check that .NET Core has been installed correctly:

    dotnet --info

    Output from dotnet --info

  5. Create a *.NET Core Console App```lang-none in Visual Studio. Set Target framework = .NET Core 3.1 (or the version you downloaded to the Raspberry Pi). Make sure that Project → Properties → Build → Output → Advanced → Debugging information = Portable.

    Advanced build settings

  6. Build the project in Visual Studio and copy all *.dll, *.pdb, *.deps.json and *.runtimeconfig.json files from the development machine to the Pi. PuTTY's pscp command can be used:

    cd bin\Debug\netcoreapp3.1
    pscp -pw <password> *.dll *.pdb *.deps.json *.runtimeconfig.json pi@192.168.0.xxx:/home/pi
  7. Open a SSH session to the Raspberry Pi and run the program, or start it from the development machine using SSH:

    ssh pi@192.168.0.xxx dotnet /home/pi/MyProgram.dll
  8. Attach to the remote process by selecting the Debug → Attach to Process menu item in Visual Studio. Select Connection type = SSH and in the Connection target textbox, type pi@192.168.0.xxx and press Enter.

    Connection target

  9. Enter password and click the Connect button.

    Connect window

  10. Click the Select button.

    Attach to process image

  11. Select Managed (.NET Core for Unix) and click the OK button.

    Select code type

  12. Select the dotnet MyProgram.dll process and click the Attach button. The first connection might take several minutes, but subsequent connections are much faster.

Enjoy setting breakpoints, adding watches, stepping through code and even using "Set Next Statement" - almost as fast as when debugging on the local machine. The only thing I'm missing so far is Edit and Continue, but not enough to investigate if it is possible to achieve.

Is it possible to remotely debug a Mono console app from Visual Studio?

It seems it is not possible with free software. I can use Visual Studio with MonoRemoteDebugger and if I have doubts about code compatibility, I can build the project in Xamarin which permits targeting Mono.

debugging dotnet core 2.0 project with monodevelop

Didn't expect that after a year it is me again to answer this question.

I just started an open source extension to hook Samsung's open source .NET Core debugger to MonoDevelop,

https://github.com/lextudio/monodevelop.netcoredbg



Related Topics



Leave a reply



Submit