views:

1524

answers:

2

I am building an internal dev tool to manage different processes commonly used in our development environment. The tool show the list the monitored processes, indicate their running state and allow to start or stop each process.

I'd like to add the functionality of attaching a debugger to a monitored process from my tool instead of going in 'Debug->Attach to process' in visual studio and finding the process.

My goal is to have something like Debugger.Launch() that would show a list of the available visual studio. I can't use Debugger.Launch() because it lauches the debugger on the process that make the call. I would need something like Debugger.Launch(processId).

Does anyone know how to acheive this functionality?

A solution could be to implement a command in each monitored process to call Debugger.Launch() when the command is received from the monitoring tool, but I would prefer something that does not require to modify the code of the monitored processes.

Side question: When using Debugger.Launch(), instances of Visual Studio that already have a debugger attached are not listed. Visual Studio is not limited to one attached debugger, you can attach on multiple process when using 'Debug -> Attach to process'.

Anyone know how to bypass this limitation when using Debugger.Launch() or an alternative?

+3  A: 

Launch the Debugger Automatically

Sheng Jiang 蒋晟
The link you provided indicate how to start a process with the debugger attached. I want to attach the debugger on a process when it is already running.After reading the article I checked the documentation about vsjitdebugger and what I exactly what I needed: vsjitdebugger -p ProcessId. Thanks for pointing me into that direction.Any idea how to attach to a visual studio that is in debugging mode? The list of Visual Studio shown in "Visual Studio Just-in-time debugger" does not display them.
SelflessCoder
What do you mean? attach a debugger to Visual Studio that is debugging something else? What is that good for?
Sheng Jiang 蒋晟
I mean to debug multiple process using only one visual studio instance. It is possible to do it from "Debug -> Attach to process", but the JIT Debugger dialog doesn't shows instances of Visual Studio that are in debugging mode.
SelflessCoder
In my case, this would be useful because the monitored processes share a common visual studio solution. This solution is pretty big and consume alot of memory, so using only one instance to debug multiple process saves alot of memory.
SelflessCoder
Then you probably need a Visual Studio Extension to automate that.
Sheng Jiang 蒋晟
+1  A: 

I doubt you are still looking for this, but here is some info about how you can programatically attach the debugger to multiple processes:

Attach to locally running processes

Attach to remotely running processes

Vilas Jagannath