Debugging Assemblies Located in the GAC
Posted by Steve Pietrek on January 2, 2008
Update: Please see this post for a better alternative.
I have been creating feature receivers which I installed to the GAC. Of course I ran into issues and needed to debug the code. Below are the steps I ran through to do so:
- Install the assembly to the GAC. There are a few ways of doing this. First, create a WSP file which installs the assembly to the GAC. Second, you can use gacutil.exe to install it.
- Select Start – Run and type in %SYSTEMROOT%\Assembly\GAC_MSIL
- Open the folder which contains the DLL.
- Open the folder with the version number and public key you are interested in.
- Open Visual Studio 2005 or Visual Studio 2008.
- In the Solution Explorer, right-click on the solution and select Properties.
- On the Build tab, set the Output Path to the folder which contains the DLL (the folder in step #4).
- Build the project. This will copy in the PDB file to the GAC folder.
- Select Debug-Attach to Process.
- Select the correct w3wp process. To know the correct w3wp process, see this post.
- Set breakpoints accordingly.
- Execute code by activating/deactivating the feature in browser.
Note: I need to do some more research on this but the breakpoints were not hit if I activated/deactivated the feature using STSADM. Breakpoints were only hit when I activated/deactivated the feature in the browser. Just something to be aware of.



Doug Ware said
Hi Steve,
I love your blog. Thanks for the great content and links!
You don’t need to copy the pdb files to debug the GAC. Please have a look at my post on this here: http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=23
ano said
In my case (dll tarfeting .NET 3.5) step 2 was:
Select Start – Run and type in %SYSTEMROOT%\Assembly\GAC_MSIL
Bijender said
thanks Steve Pietrek thats very nice post