views:

287

answers:

2

I have a pre-alpha GUI program that I'm dogfooding and want to run under the debugger (for when things go wrong ;) but I don't want to have to launch a new copy of VS for each instance of the App. Can this be done?

I don't expect to actually be debugging more than one instance at a time, but still want the debugger in the look for all of them. Also I'm starting the app a few dozen time a day so it would have to be easy to do.

+2  A: 

This can be done.

If you have the Professional version of Visual Studio, you can use it to attach to each instance of the app that you have open.

First, compile the app with debug info so that it can actually be debugged.

Then launch your app. Open as many instances as you need.

In Visual Studio click "Debug > Attach to Process..." from the top menu. Select the process(es) you want to debug. You can select more than one from the list by Shift+Clicking or Ctrl+Clicking them.

I've just tested this to make sure. Once instance of Visual Studio (at least 2008) can debug multiple instances of the same application.

If you don't have the Pro version I don't think this can be done. I'm absolutely sure the express version can not attach to processes. I'm not sure about what "paid" editions can attach to processes though it is possible to do.

Dan Herbert
You can only attach to one instance, and if visual studio is already watching the process, you can't attach again.
scottm
I just tried this myself and it works. Obviously you can't attach to the SAME process more than once, but if you open multiple instances you can attach to each separate process. This works.
Dan Herbert
Yuck, Not near as nice a "just hit F5" but +1 anyway.
BCS
Well you learn something new every day
Binary Worrier
It might not be pretty, but this type of thing is done so rarely that I guess MS didn't feel it needed an easy solution.
Dan Herbert
+1  A: 

You can start an instance of the same, or different projects multiple times in one instance of visual studio. Here is how: Right click on any project in Solution Explorer, go to Debug, and click Start New Instance.

You can view and manipulate all your running processes from the Processes window. (Debug -> Windows -> Processes)

Marcin