Visual Studio: How to attach a debugger dynamically to a specific process

Posted by Jeff Cyr on Stack Overflow See other posts from Stack Overflow or by Jeff Cyr
Published on 2009-10-26T18:22:22Z Indexed on 2010/06/09 21:22 UTC
Read the original article Hit count: 321

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about debugger