Click here to Skip to main content
12,354,533 members (56,944 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.2K views
9 bookmarked
Posted

How to Debug Windows Services and Plugins

, 26 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
How to Programatically (and configurably) Launch a Debugger
If you’ve ever had to create an component hosted inside a third party application (such as a plugin or Windows service), you’ll know that it can be pretty tricky to get the debugger attached to the process quickly and reliably. Here’s a snippet that I’ve taken from project to project:

#if DEBUG
            if (Properties.Settings.Default.LaunchDebugger
                && !System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Launch();
#endif

This statement checks to see if launching the debugger is allowed (using the standard settings classes) and launches the debugger if one isn’t already attached.

For release builds, the entire line is removed from code to avoid ‘accidental’ debugging.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Martin Jarvis
Software Developer (Senior) Freestyle Interactive Ltd
United Kingdom United Kingdom
I'm a lead developer for Freestyle Interactive Ltd where we create many wonderful websites built on Microsofts ASP.Net and Ektron CMS.

I've been developing .Net applications (both Windows and Web) since 2002.

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 5 That's considerably better than my #... Pin
TheyCallMeMrJames28-Jun-10 10:32
memberTheyCallMeMrJames28-Jun-10 10:32 
GeneralThat's considerably better than my #if DEBUG...Sleep(15000) ... Pin
TheyCallMeMrJames28-Jun-10 10:31
memberTheyCallMeMrJames28-Jun-10 10:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 26 Jun 2010
Article Copyright 2010 by Martin Jarvis
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid