Debugging .NET Core on WSL by launching directly from Visual Studio - visual-studio

Everything I've read about debugging C# programs on Windows Subsystem for Linux either uses Visual Studio Code, or tells you to launch the program through bash then attach the debugger to the process.
This method works, but it's slow to initiate every time I'd like to debug a change. Is there a way to setup Visual Studio to start remote debugging from the IDE similar to how it's done in C++?

You can debug the .Net Core application on WSL2 from Visual Studio 2019 now.
You need to install/update to version Visual Studio 2019 v16.9.1.
There are the Prerequisites, You can refer to Start debugging with WSL 2.

Related

Run an executable in WSL from a Visual Studio launch profile

In Visual Studio in Windows I can create a launchSettings.json profile which starts up an executable I specify and then attaches to it. Is it possible to do the same with an executable in WSL?
I'm writing an extension to a Linux program. The extension is a .Net 6 class library, so in order to debug it I need to start up the Linux program and then immediately attach. I could start up the program manually and then attach to the process from Visual Studio, but the extension loads first thing and I can't hop over to Visual Studio and attach fast enough to catch it.
I've found instructions for debugging .Net ASP and console apps in WSL from Visual Studio, but those instructions always assume that the project I'm debugging is itself executable.

How do I create a batch file that supports an older version of Visual Studio

I have been building Smart Device application on Visual Studio 2008 and have been using a batch file to do so.
This has been working until I have installed Visual Studio 2015 and I wanted to still build and debug the solution via Visual Studio 2008 because Visual Studio 2015 doesn't support Smart Device development. However, using the same batch file I can no longer do so.
I am looking for a way to be able to target the devenv of the older version of Visual Studio for the batch file without uninstalling Visual Studio 2015, because I too have projects built on that version.
NOTE: I can run Visual Studio 2008 perfectly fine and using their on-click build tool it builds fine.
The batch file is probably picking up environment variables (INCLUDE, LIB etc) set up by VS 2015, which the 2008 toolset will not work with.
The Visual Studio 2008 menu should have a Visual Studio Tools submenu. Run Visual Studio 2008 Command Prompt from that submenu, which will open a cmd console with the VS 2008 environment set correctly. Run your batch file at that prompt.
You can automate it by writing a small batch file to first execute vcvarsall.bat (which is what the menu command does), then run your batch.
#call "<path-to-vs2008-install-directory>\vcvarsall.bat" x86
#call "<your-batch.bat>"

Debugging information does not match, when using v60 platform toolset inside Visual Studio 2013

I am using Visual Studio 2013, but I'm in need to develop an old project using the Visual C++ 6.0 compiler.
For this purpose, I have been using Daffodil with no problem on Windows 8.1 for a while.
(You can read more how to use the VC++ 6 compiler in newer Visual Studio versions in this StackOverflow question: Is it possible to use the VC++ 6 compiler in Visual Studio 2012?)
Now I got a new Windows 10 machine, where I reinstalled Visual Studio 6, 2010, 2013 and Daffodil.
Using v60 build tools (Visual C++ 6.0 compiler), project gets compiled fine.
However, when I try to debug, VS says that "debugging information does not match", and I am unable to set breakpoints etc., but:
PDB file is there, same folder and name of debug executable;
Application built in Debug mode, with debug information enabled;
Debugger works fine when using Visual Studio 2010 or 2013 build tools;
Debugger works fine if opening the project inside Visual C++ 6 IDE.
I tried reinstalling all Visual Studio versions as well as Daffodil, but didn't solve.
Any clue what could the problem be?
Finally I actually found a working solution!
for VS 2013:
Enable "Native Edit and Continue"
under Tools->Options->Debugging->Edit and Continue
for VS 2015:
Enable "Use Native Compatibility Mode"
under Tools->Options->Debugging->General

sos.dll usage in visual studio 2013

When I am reading docs about sos.dll #MSDN, encounter a note says
If you are using Visual Studio 2013, SOS.dll is supported in the Windows Debugger within Visual Studio
I know how to use sos.dll in the immediate window in Visual Studio 2012. But how to use sos.dll with visual studio 2013 debugger?
From MSDN documentation of What’s New for the Debugger in Visual Studio 2013 (Excerpt from the part Debug With Debugging Tools for Windows)
The SOS.dll (SOS Debugging Extension) that helps you debug managed
programs in WinDbg, is not available from the Visual Studio IDE. See
Debugging Managed Code Using the Windows Debugger
Looks like you may need to load them separately as being said Here
I couldn't get sos.dll to load in Visual Studio 2013 no matter what I tried.
I've resorted to good old WinDbg instead. I know it's not an ideal answer, but it appears to be the only possible solution to debugging with sos.dll. I'd really like to use sos.dll in Visual Studio 2013, but WinDbg isn't so bad once you learn its basics. It's actually very powerful, even if you know very little about the unmanaged world (like me).
How to load SOS in WinDbg
Yes you can use SOS from VS 2017. But you will need to install windows driver kit (WDK). Here is a screenshot of me debugging a process with command line debugger within VS 2017.
https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/setting-up-user-mode-debugging-in-visual-studio

Visual Studio 2010 configuration

I have a Windows 32-bit project designed in Visual Studio 2010 using C++. When I build and compile it on one computer, I get the GUI and the project works. However, on a different computer it only shows me a command prompt and then exits. What configuration changes do I need to make to see the GUI on this computer?

Resources