Having C# Code Launch the debugger

By | 2008-01-24

Sometimes you have a library running outside of your traditional debug mode, but would like to call into it with a debugger. I specifically ran into this with a custom installer dll called by a custom action in my MSI. The following code will allow the process itself to request debugging. Then you can specify your favorite debugger, and you’re on your way.

#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif

(The #if DEBUG / #endif, tells this only to be apart of the debug builds.)

Leave a Reply

Your email address will not be published. Required fields are marked *