Fred
Fred

Reputation: 747

Visual Studio: debug multiple projects at the same time?

Is it possible to debug multiple projects at the same time in Visual Studio?

I know you can select multiple startup projects from the solutions properties, but how are the breakpoints handled?

If two projects use the same class (two different instances of it), and I am stopped with a breakpoint in it, will it only block one program or both? How can I know which executable is hitting the breakpoint? I'm a bit confused.

Upvotes: 27

Views: 19328

Answers (2)

Bob Moore
Bob Moore

Reputation: 6894

No. You can debug an EXE file and step into a debug version of a linked DLL file, if you're careful about making sure the EXE file "sees" the same DLL file as the debugger, but you can't debug two EXE files at the same time. At least as far as I'm aware.

Upvotes: -2

Jimmy
Jimmy

Reputation: 28376

Yes, it is possible. You can set multiple startup projects in your solution (right-click solution, go to Set Startup Projects, choose Multiple startup projects), and specify the action for each project contained in the solution (None, Start, Start without debugging). If you have multiple projects set to Start, the debugger will attach to each one as it launches.

When you hit a breakpoint, you can see which process you're in using the Debug Location toolbar (you may have to show it; some profiles hide this by default). It will show which process you're currently looking at, which thread you're on, and which stack frame you're in:

Debug Location toolbar

I believe the default behavior is that when one process breaks, the debugger will break all of them. This way you can check the state of any attached process when you hit a single breakpoint.

Upvotes: 54

Related Questions