How to: Remove an Assembly from the Global Assembly Cache

Note

This article is specific to .NET Framework. It doesn't apply to newer implementations of .NET, including .NET 6 and later versions.

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

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.

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

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.

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.

See also