ANTS Performance Profiler 9

Profiling an assembly in the Global Assembly Cache (GAC)

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 .

  1. From a command prompt, run:

    regsvr32 /u %systemroot%\\framework\v2.0.50727\shfusion.dll
  2. Open the GAC folder by using start->run and typing and running %systemroot%\assembly\GAC_MSIL
  3. Open the folder that has the same name as your assembly. 
  4. 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. 
  5. Copy the PDB file into the relevant folder.
  6. Return the GAC folder to its original state by re-registering shfusion.dll. From a command prompt, run:

    regsvr32 %systemroot%\\framework\v2.0.50727\shfusion.dll

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.

Didn't find what you were looking for?