views:

66

answers:

4

I have multiple projects in one solution. Project A (the starting project) starts Project B using Process.Start.

All the debugging methods work fine in project A, however after A starts B, not only do breakpoints not work, but also the output from calls to System.Diagnostics.Debug.WriteLine is not displayed.

Does anyone know how to debug in this situation?

+1  A: 

The new process which is created at runtime will not have the debugger attached hence breakpoints and debug.writeline won't work.

You might be able to select "Debug" menu then "Attach to process" from within Visual Studio once the new process is running.

DaveHogan
Thanks for your answer
Prophet
+1  A: 

You are debugging the process that Project A is working and because you are starting a second process for Project B you have not attached your debugger to that process. So you need to attach to the second process.

BitOff
Thanks for your answer
Prophet
+2  A: 

In this scenario you have 2 processes running and you need to attach Visual Studio to both of them. Visual Studio supports attaching to multiple processes and getting it to do so is the same as attaching to a single process. Once the second process is launched do the following

  • Tools -> Attach to Process
  • Select the process
  • Hit Attach
JaredPar
Thanks for your answer. I think I need to add some blocking codes in the beginning of project b.
Prophet
@Prophet, why not just add a `Debug.Break` call?
JaredPar
@Jared: You mean `Debugger.Break`. http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx
Steven Sudit
nice ! first time see this awesome function.
Prophet
@Steven, yes, thanks
JaredPar
Thank you so much
Prophet
A: 

You could add an call to System.Diagnostics.Debugger.Launch(); in the Main from Project B. So every time you start Project B it will ask you if you want to attach a Debugger.

Noffls