Search code examples
c#visual-studio-2010c#-4.0remote-debugging

Visual Studio remote debugging on application startup


As I understand it now, the only way to use the remote debugger is to start the target application, and then attach to it through Visual Studio. Is there a way to capture all of the breakpoints from the very beginning of the program?

There is code within my program that I need to debug, and I can never get the debugger attached fast enough to capture that executing code.


Solution

  • If you can change the code, try injecting this line of code in the starting point of your app:

    System.Diagnostics.Debugger.Launch();
    

    When this line is hit it will prompt you to attach a debugger, effectively waiting for you to respond. Since you are using a remote debugger you should be able to attach at that point and then just cancel the dialog. Hope this helps.