locked
How to debug project B when started by project A (in same solution)? RRS feed

  • Question

  • I have a Visual Studio 2015 solution with two projects, AppA and AppB. At a certain point, AppA launches AppB. I would like the debugger to start running when AppB is launched by AppA so I can set breakpoints, etc, in AppB, but I don't know how to set this up.

    Any help would be appreciated!! Michael

    Tuesday, February 16, 2016 7:41 PM

Answers

  • An invasive technique is the most effective.  Make it so that the first thing your AppB program does is show a message box that says "Attach debugger now".  Then when AppA launches AppB, and the message box appears, use the Debug > Attach to Process... option in Visual Studio to attach the debugger to your process.  Then after the debugger is attached, set any breakpoints you need to set and click the button in your message box to resume execution of AppB.

    You can make use of command line arguments to selectively enable this "Attach debugger now" feature for a particular instance of the process if AppA launches multiple instances of AppB.



    • Edited by Wyck Wednesday, February 17, 2016 6:05 AM
    • Proposed as answer by Weiwei Cai Monday, February 22, 2016 9:47 AM
    • Marked as answer by Weiwei Cai Thursday, February 25, 2016 3:13 AM
    Wednesday, February 17, 2016 6:04 AM
  • Thanks for Wyck'e reply.

    Hi Veloz,

    Please try Wyck's suggestion first.

    Another way to debug the project when another project is debugging is that:

    1. Right-click your project B to choose Debug -> Start new instance. Then the project B start to run.
    2. Right-click your project A to choose Debug ->Start new instance. Now the project A start to debug too when the project B in debug.

    Best Regards,
    Weiwei

    • Proposed as answer by Weiwei Cai Monday, February 22, 2016 9:47 AM
    • Marked as answer by Weiwei Cai Thursday, February 25, 2016 3:13 AM
    Wednesday, February 17, 2016 7:04 AM

All replies

  • An invasive technique is the most effective.  Make it so that the first thing your AppB program does is show a message box that says "Attach debugger now".  Then when AppA launches AppB, and the message box appears, use the Debug > Attach to Process... option in Visual Studio to attach the debugger to your process.  Then after the debugger is attached, set any breakpoints you need to set and click the button in your message box to resume execution of AppB.

    You can make use of command line arguments to selectively enable this "Attach debugger now" feature for a particular instance of the process if AppA launches multiple instances of AppB.



    • Edited by Wyck Wednesday, February 17, 2016 6:05 AM
    • Proposed as answer by Weiwei Cai Monday, February 22, 2016 9:47 AM
    • Marked as answer by Weiwei Cai Thursday, February 25, 2016 3:13 AM
    Wednesday, February 17, 2016 6:04 AM
  • Thanks for Wyck'e reply.

    Hi Veloz,

    Please try Wyck's suggestion first.

    Another way to debug the project when another project is debugging is that:

    1. Right-click your project B to choose Debug -> Start new instance. Then the project B start to run.
    2. Right-click your project A to choose Debug ->Start new instance. Now the project A start to debug too when the project B in debug.

    Best Regards,
    Weiwei

    • Proposed as answer by Weiwei Cai Monday, February 22, 2016 9:47 AM
    • Marked as answer by Weiwei Cai Thursday, February 25, 2016 3:13 AM
    Wednesday, February 17, 2016 7:04 AM