How to: Remove an Assembly from the Global Assembly Cache

 

There are two ways to remove an assembly from the global assembly cache (GAC):

  • By using the Global Assembly Cache tool (Gacutil.exe). You can use this option to uninstall assemblies that you've placed in the GAC during development and testing.

  • By using Windows Installer. You should use this option to uninstall assemblies when testing installation packages and for production systems.

Removing an assembly with Gacutil.exe

  1. At the command prompt, type the following command:

    gacutil –u <assembly name>

    In this command, assembly name is the name of the assembly to remove from the global assembly cache.

    System_CAPS_ICON_warning.jpg Warning

    You should not use Gacutil.exe to remove assemblies on production systems because of the possibility that the assembly may still be required by some application. Instead, you should use the Windows Installer, which maintains a reference count for each assembly it installs in the GAC.

The following example removes an assembly named hello.dll from the global assembly cache.

gacutil -u hello  

Removing an assembly with Windows Installer

  1. From the Programs and Features app in Control Panel, select the app that you want to uninstall. If the installation package placed assemblies in the GAC, Windows Installer will remove them if they are not used by another application.

    System_CAPS_ICON_note.jpg Note

    Windows Installer maintains a reference count for assemblies installed in the GAC. An assembly is removed from the GAC only when its reference count reaches zero, which indicates that it is not used by any application installed by a Windows Installer package.

Working with Assemblies and the Global Assembly Cache
How to: Install an Assembly into the Global Assembly Cache
Gacutil.exe (Global Assembly Cache Tool)

Show: