Debugger.Launch() codesnippet

If you are like me, tired of writing “System.Diagostics.Debugger.Launch()”, when debugging feature receivers (or something else in Sharepoint), here´s a tip for you.
Use a code snippet (an xml file in in fact). Either you open an existing snippet (on Vista they are located here: (C:\Program Files x86\Microsoft Visual Studio 9.0\VC#\Snippets\1033 ) or create a new xml file that you give the extension of .snippet

Here´s the snippet for debugger.launch:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="">
    <CodeSnippet Format="1.0.0">
            <Description>Code snippet for Debugger.Launch()</Description>
            <Author>Johan Leino</Author>
            <Code Language="csharp">
            #if DEBUG

The value in the Shortcut node  is what you write in VS to show your snippet (like “prop” or “ctor”), in this case “dl”.

Save your snippet to (location may differ depending on operating system):
Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets\[your name].snippet

So when you write “dl” the snippet appears and you just press TAB to insert it, like this:




  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: