Visual Studio remote debugging on application startup

Tim picture Tim · Mar 27, 2012 · Viewed 7.1k times · Source

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.

Answer

BenR picture BenR · Mar 27, 2012

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.