Tag: debugging

Debugging C# on Ubuntu and you get

Debugging C# on Ubuntu and you get


So you’re trying to debug C# code on Linux, maybe Ubuntu. You’ve installed .NET 6 or 7, you’ve built your solution in Visual Studio on your Windows PC, published it then copied the files over to the Linux box. But when you run it, you get an error “Unable to find debugger script at”. It’s time to debug your Linux app from your Windows Visual Studio.

Now there is a Microsoft support issue for this and it’s less than helpful. Read below to see how I fixed it.

Only, as soon as it tries to attach over SSH (with username, password, IP etc), you get this popup on the left. “Computer says no”.

Looking in the VS Output folder you see the text below or something similar. For whatever reason, it failed to create a hidden folder in your home folder. To fix this, all you have to do is create that folder. It’s .vs-debugger under your home folder.

If you’re not familiar with .folders on Linux, note that the . at the front of the name means it’s a hidden folder. A simple ls command will not reveal it. If you use the File Manager, you can click the settings in the top right and tick the Show Hidden Files. Then you can do a cd ~ followed by a mkdir .vs-debugger. And View in files to confirm that it’s there.

Now the only pain with debugging is that the application must be running for Visual Studio to attach to it. I was debugging a utility that is run, does its business and closes. So to debug it, I added this as the first line in main() in program.cs


So run it, let it sit waiting for a key then attach visual studio’s debugger to your app over SSH, add your breakpoints and hit a key. Simples!

I do like Visual Studio Code

I do like Visual Studio Code

Visual Studio Code MarketplaceWhen I wrote the Windows version of the book I used Visual Studio and it was quite excellent. But Visual Studio Code (VSC), the free cross-platform IDE is also very impressive.

Not only does it let you create your own extensions but you can even include debugging and visual debugging like Visual Studio.

I installed Clang and it’s associated debugger lldb. It is pretty powerful, The only thing that is a bit difficult with VSC is the learning curve for configuring builds, etc. With the Microsoft C/C++ extension there are four JSON files that must be configured for compiling, debugging etc.

The picture is from the website for the Visual Studio code marketplace. There are currently over 16,000 extensions most if not all (I haven’t checked them all!) are free and support virtually every popular programming language and probably one or two I haven’t heard of.