Debugging in the GAC is harder than in the BIN because you cannot copy
the PDB (VS.NET symbols) there using conventional drag and drop or the
GacUtil. There is a hack that I use that helps me debug assemblies
directly from within the GAC, but I'm not sure how conventional it is.
From Start > Run type the following command:
%systemroot%\Assembly\GAC_MSIL
Locate your Assembly folder and drill down to the DLL. This is where the
GAC is really storing your DLL. Copy the PDB file from your VS.NET
projects \bin\debug subdirectory each time you recompile your assembly
(I typically use an XCOPY in the Post Build Events). You will also have
to recycle the AppPool each time you recompile because the .NET
Framework is actually running a shadow copy of your DLL and the recycle
will flush the cache. I use this command, also in the Post Build Events,
to recycle the AppPool:
%systemroot%\system32\iisapp.vbs /a "SharePointAppPool" /r
where SharePointAppPool is the name of the AppPool that your Web
Application is using. If that doesn't work, you can always run an
iisreset; it just takes longer.
With the right Post Build Events in place (GacUtil for DLL, XCopy for
PDB, and the AppPool recycle) I use a systematic approach each time
(presumes that you already have a break point set): Change code, rebuild
(not just build), refresh in the browser, attach to the W3WP process,
refresh in the browser again to hit your break point. While the first
refresh in the browser isn't required, I find that things don't get out
of sync as often using these steps.
Now you should be able to debug your assembly while it is still in the
GAC.