SUBST, GAC and SharePoint

Working with SharePoint, sometimes you just have to install assemblies to the GAC. An example of this I have had to deal with recently was writing a webpart to access methods in the UserProfileManager class.

Debugging GAC installed assemblies can be a bit frustrating, hopefully the following steps will make it alot easier and obvious....

1. Install the assembly into the GAC

2. Map a drive using SUBST to %SYSTEMROOT%\assembly

SUBST maps a drive to a path - http://www.microsoft.com/technet/archive/msdos/07_refer.mspx?mfr=true 

A mapped drive does not use the Assembly Cache Viewer and will show you the true folder structure.

3. Locate and open the GAC_MSIL folder in the mapped drive

4. Locate and open the folder containing your assembly. The name of the folder is the same as the assembly name.

5. Copy the pdb (program database) file from your project build folder to your assembly folder in the GAC. Because you have mapped a drive to %SYSTEMROOT%\assembly you should be able to do this easily with Windows Explorer.

6. Do an iisreset /noforce (this is not really required but usually helps - general rule of thumb for working with SharePoint).

7. Go to Visual Studio and attach the debugger to the w3wp.exe (remember there may be more than one depending on how many app pools you have).

You should now be able to hit the breakpoints you have set.