Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

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:

  1. 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.
  2. Select Start – Run and type in %SYSTEMROOT%\Assembly\GAC_MSIL
  3. Open the folder which contains the DLL.
  4. Open the folder with the version number and public key you are interested in.
  5. Open Visual Studio 2005 or Visual Studio 2008.
  6. In the Solution Explorer, right-click on the solution and select Properties.
  7. On the Build tab, set the Output Path to the folder which contains the DLL (the folder in step #4).
  8. Build the project. This will copy in the PDB file to the GAC folder.
  9. Select Debug-Attach to Process.
  10. Select the correct w3wp process. To know the correct w3wp process, see this post.
  11. Set breakpoints accordingly.
  12. 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.


3 Responses to “Debugging Assemblies Located in the GAC”

  1. 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

  2. ano said

    In my case (dll tarfeting .NET 3.5) step 2 was:

    Select Start – Run and type in %SYSTEMROOT%\Assembly\GAC_MSIL

  3. Bijender said

    thanks Steve Pietrek thats very nice post

Sorry, the comment form is closed at this time.

%d bloggers like this: