How to debug a .NET custom action during an installation process.

I'm building a setup project for a windows service, and it has been a matter of some annoyance that I've not been able to debug the custom actions I've written in .NET during the installation process.  I've finally hacked together a way to do this which has made the process of developing the custom action enormously easier.

First let me say that I have searched for ways to do this before and have been unable to find them. If anyone has a better way, then I'd be glad to hear it as what I'm about to add is something of a hack.

If you want to debug a custom action during installation, add a modal dialog form to the beginning of the function you wish to test. Place a breakpoint anywhere after the call to the modal dialog form. Run the installation. When the modal dialog form pops up, go to the Debug->processes menu. Look for the msiexec processes, and find the one that refers to your dialog (usually indicated by the form's caption). Attach to the process. Now, close the dialog form, and watch the code execution stop on your breakpoint.

The dialog form serves as a processes interrupt that gives you time to attach to the process at the place your interested in.

While this approach has "hack" written all over it, I can't think of another way to do this. If you know of something better, tell me and I'll post it.


UPDATE

There is a better method here:

http://weblogs.asp.net/josh.robinson/archive/2004/12/20/327381.aspx

Thanks Josh!

Comments

# re: How to debug a .NET custom action during an installation process.

Friday, February 11, 2005 3:21 PM by Josh Robinson

This is also a hack, but here is a link to the technique I use: http://weblogs.asp.net/josh.robinson/archive/2004/12/20/327381.aspx

Leave a Comment

(required) 
(required) 
(optional)
(required)