IanG on Tap

Ian Griffiths in Weblog Form (RSS 2.0)

Blog Navigation

April (2018)

(1 item)

August (2014)

(1 item)

July (2014)

(5 items)

April (2014)

(1 item)

March (2014)

(1 item)

January (2014)

(2 items)

November (2013)

(2 items)

July (2013)

(4 items)

April (2013)

(1 item)

February (2013)

(6 items)

September (2011)

(2 items)

November (2010)

(4 items)

September (2010)

(1 item)

August (2010)

(4 items)

July (2010)

(2 items)

September (2009)

(1 item)

June (2009)

(1 item)

April (2009)

(1 item)

November (2008)

(1 item)

October (2008)

(1 item)

September (2008)

(1 item)

July (2008)

(1 item)

June (2008)

(1 item)

May (2008)

(2 items)

April (2008)

(2 items)

March (2008)

(5 items)

January (2008)

(3 items)

December (2007)

(1 item)

November (2007)

(1 item)

October (2007)

(1 item)

September (2007)

(3 items)

August (2007)

(1 item)

July (2007)

(1 item)

June (2007)

(2 items)

May (2007)

(8 items)

April (2007)

(2 items)

March (2007)

(7 items)

February (2007)

(2 items)

January (2007)

(2 items)

November (2006)

(1 item)

October (2006)

(2 items)

September (2006)

(1 item)

June (2006)

(2 items)

May (2006)

(4 items)

April (2006)

(1 item)

March (2006)

(5 items)

January (2006)

(1 item)

December (2005)

(3 items)

November (2005)

(2 items)

October (2005)

(2 items)

September (2005)

(8 items)

August (2005)

(7 items)

June (2005)

(3 items)

May (2005)

(7 items)

April (2005)

(6 items)

March (2005)

(1 item)

February (2005)

(2 items)

January (2005)

(5 items)

December (2004)

(5 items)

November (2004)

(7 items)

October (2004)

(3 items)

September (2004)

(7 items)

August (2004)

(16 items)

July (2004)

(10 items)

June (2004)

(27 items)

May (2004)

(15 items)

April (2004)

(15 items)

March (2004)

(13 items)

February (2004)

(16 items)

January (2004)

(15 items)

Blog Home

RSS 2.0

Writing

Programming C# 5.0

Programming WPF

Other Sites

Interact Software

Debugging Applications Launched from Outside the Debugger

Friday 19 November, 2004, 11:49 PM

From time to time it's useful to be able to debug an application without launching it from within the debugger - sometimes you need to start programs in their natural launch environment to reproduce a problem. Of course you can always attach the debugger to an existing process, but this doesn't work so well if you need to debug it from startup rather than attaching once it's running. (E.g., maybe it's crashing on startup.)

Fortunately you can tell Windows that you'd like to do this, and have it automatically fire up a debugger for you whenever a particular application is launched. And despite the fact that this has been written about before, I always forget the details, so I thought I'd blog them - that way I know where to look next time I need to do this! And lots of people don't seem to know about this, so it's worth bringing up anyway.

The trick is to add a registry key underneath this one:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

Underneath here you'll find lots of names of executables. You can add a key with the name of the executable you'd like to debug as soon as it starts. Just put in the file name without the path (but including the .EXE extension). And underneath that key add a string value called Debugger. In here you can specify the name of a program to be used as a debugger (including the path this time, unless your debugger happens to be on your system path). With this in place, whenever something tries to run the program, your chosen debugger will run instead.

Note: the Debugger value must not contain any spaces. If necessary, use the 8.3 style path. (The DOS legacy still has its uses...)

So what do you choose as the debugger program? Well, you can just point the VS.NET exe, devenv.exe at it, passing in the /debugexe switch. Or you can use the vs7jit.exe launcher.

The one problem with these is that they will fire up a new debugger instance. This is a pain if you wanted to open a particular VS.NET project, or attach with an instance that is already running, like you can do with the normal JIT debugging dialog.

This gets better with Whidbey. If you've got VS.NET 2005 installed, just use vsjitdebugger.exe as the debugger. This gets installed on the system path, so you don't even need to specify its location - just the name is fine. This brings up the same debugger picker UI you get when JIT debugging, enabling you to choose either a new debugger instance or one that's already running.

(I got really confused by this earlier today. My machine has a copy of vsjitdebugger.exe because it had a beta of Whidbey installed at one point in the past. It didn't get removed when I took the beta off. And since that's been the JIT debugger executable on my system for ages, I hadn't realised it was a whidbeyism, and so it took me a while to work out why it wasn't present on a colleague's machine... *Sigh* Still, it's handy that it happens to work with VS.NET 2003!)

Copyright © 2002-2024, Interact Software Ltd. Content by Ian Griffiths. Please direct all Web site inquiries to webmaster@interact-sw.co.uk