Welcome to Atalasoft Community Sign in | Help

Debugging Code in the GAC - the best thing since sliced bread

I've been playing around with writing a VS Project Template that includes a Wizard implemented in C#.  I had done something similar many years ago when the only choice was C++, and boy have things gotten way better.

Before doing anything else, I read a lot and one thing that caught my eye was that any assembly that is to be used as an add-in needs to be signed and installed in the GAC.  This is troublesome as I always assumed that debugging code built this way was going to be, well, a pain in the GAC.

Some googling time later, I found several people who had succeeded, but again with pain - I assumed that this was my lot too.  Then I found this blog entry.  Run.  Don't walk there and read.  It is step by step instructions on how to set up VS to debug code installed in the GAC.  It works and it works well.  Thanks Doug, for figuring this out and making it available.

This is only half the picture though - to make this a really smooth experience, I added the following to the post-build step in the "Build Events" pane.

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil" -I "$(TargetPath)" /f

This works for Visual Studio 2005, since it has the path to gacutil built-in.  The line basically means "forcibly install the assembly I've just built into the GAC".

The final bit of icing is to change the Start Action in the Debug pane to "Start external program" and set the path to:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe

When you "run" your assembly, it will fire up a new instance Visual Studio and that will allow you to debug your IWizard derived class at the source level.

I'm so pleased at the incredible lack of pain I'm feeling.  The pain was all in figuring out how to win the trivia contest before I began.

Published Thursday, July 24, 2008 3:07 PM by Steve Hawley

Comments

Friday, July 25, 2008 12:02 PM by DotNetKicks.com

# Debugging Code in the GAC - the best thing since sliced bread

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Anonymous comments are disabled