Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the pid of Visual Studio which is debugging my process

I know I can find if a process is being debugged via a call to Debugger.IsAttached in .NET, but I'd like to be able to get the PID of the Visual Studio that is the debugging the processes. Is this possible?

like image 774
Robert Avatar asked Jun 22 '12 10:06

Robert


People also ask

How do you find the PID of a process?

Task Manager can be opened in a number of ways, but the simplest is to select Ctrl+Alt+Delete, and then select Task Manager. In Windows, first click More details to expand the information displayed. From the Processes tab, select Details to see the process ID listed in the PID column. Click on any column name to sort.

How can I see debugging variables?

The most commonly used way to look at variables is the DataTip. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable.

What is debug code in Visual Studio?

One of the key features of Visual Studio Code is its great debugging support. VS Code's built-in debugger helps accelerate your edit, compile, and debug loop.


1 Answers

You could use the TryGetVSInstance method outlined in this answer to get a hold of each instance of Visual Studio's EnvDTE COM Automation object. Once you have that, just iterate the DTE.Debugger.DebuggedProcesses collection and check if any of them are pointing to the same processID as the process you're interested in.

like image 165
Omer Raviv Avatar answered Oct 13 '22 22:10

Omer Raviv