Profiling an assembly in the Global Assembly Cache (GAC)
Published 11 June 2013
When profiling assemblies that are loaded from the Global Assembly Cache, no results may be shown when using the 'profile only methods with source code' setting of the performance profiler. The memory profiler may not show any source code for the methods in a particular assembly loaded from the GAC.
This occurs because the PDB (debugging symbols) file is not saved into the same folder as the assembly being profiled. When the assembly resides in the GAC, this is an additional complication, because the %systemroot%\assembly folder that contains all of the files in the GAC is abstracted by shfusion.dll, which automatically registers assemblies that are dropped onto the folder, making it difficult to add the PDB files into the same folder as the dll. There are two ways to solve this problem.
Create a global debugging symbols folder
The disadvantage to this method is that you cannot have multiple version of the same assembly's PDBs in this folder, as you can different versions of the same DLL in the GAC folder.
First, create a "global" PDB folder and copy your assemblies there. To create a PDB folder, create a folder called "symbols" in the system root folder, and a dll subfolder, for instance %systemroot%\symbols\dll
Copy your assemblies' PDB files into this folder, and ANTS Profiler can then resolve the source code location for that assembly installed in your GAC.
Manually copy the PDB to the GAC
Secondly, you can copy the PDBs into the same folder as the assembly installed in the GAC. In order to view the GAC folder as a normal folder, you will need to unregister shfusion.dll .
From a command prompt, run:
regsvr32 /u %systemroot%\microsoft.net\framework\v2.0.50727\shfusion.dll
- Open the GAC folder by using start->run and typing and running %systemroot%\assembly\GAC_MSIL
- Open the folder that has the same name as your assembly.
- Find the subfolder containing the assembly being profiled.
To do this you need to know the version number. There will be a different subfolder for each individual version of the assembly that you have registered into the GAC.
- Copy the PDB file into the relevant folder.
Return the GAC folder to its original state by re-registering shfusion.dll. From a command prompt, run:
Now, ANTS Profiler will be able to filter the session to show only methods with source code, even though the assembly resides in the GAC.