Click here to Skip to main content
13,055,490 members (47,325 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


9 bookmarked
Posted 24 Jun 2010

How to Debug Windows Services and Plugins

, 26 Jun 2010
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 (Properties.Settings.Default.LaunchDebugger
                && !System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Launch();

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.


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


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.

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