Friday, November 03, 2006
Have you ever wanted to debug some .Net code that you have running in some other process that you just can't get into? I recently had the problem with Custom Actions in a Windows Installer. The custom action is a .Net Installer class that I wanted to debug. But I couldn't just attach the debugger to the running msiexec instance. It wouldn't hit my breakpoints.

This is where the System.Diagnostics.Debugger class comes in real handy. It's got a method called Launch() that will tell Windows to open a debugger. You get this dialog box asking you if you want to debug the code, and what debugger to attach:



If you have Visual Studio up and running you can attach it. The debugger stops right at the Attach() method call just like if it was a breakpoint.




By the way, as a sidenote to the custom actions, the custom action argument name that holds the virtual directory name in a Web Setup installer is [TARGETVDIR]. Took me some googling about to figure that out. Good info here.