I have C# VS 2012 solution with two projects: ProjectA and ProjectB. Both projects are console applications for the sake of simplicity.
ProjectA needs to be started first so it is set as the "Startup project" for the solution. When I run ProjectA with F5 under debugger there are some operations it needs to performs after which it should start ProjectB under the same debugger. So if I set breakpoint in ProjectB first line, debugger should break.
Is there any way I can do this? Currently I use Process.Start("path_to_projectB.exe") but that needs to be replaced with something like "Process.StartUnderSameDebugger("path_to_projectB.exe")". I want to use the same instance of VS debugger that started ProjectA for ProjectB.
Note that I don't want to use "Start multiple projects" option in Visual Studio. If I do this both console apps are started simultaneously (which is unwanted) and under the same debugger (which is wanted). First process must perform some stuff before it can start second process and that's why I can't use this approach.
Also when I later stop debugger both processes (console apps from ProjectA and ProjectB) should be closed.
You can always manually right click-debug the second project after the first project has started- both will end when the debugger stops.
The Visual Studio team has released a Visual Studio extension that allows automatically attaching child processes to the current debugger: Introducing the Child Process Debugging Power Tool.
So you can start your
ProjectB
fromProjectA
withProcess.Start
and it will automatically attach the debugger to this second process.It is available on the Gallery for Visual Studio 2013 and above.
You can also check my answer here for how to attach the current debugger to any process you may start. Note that it would not be as immediate as the Visual Studio extension since the debugger would be attached after the process has started.
These options
linked files
(Add Existing Item
->Add
(select drop downadd as link
)) and replicate the process needed to be tested.