The Gacutil application is the most common tool for installing/uninstalling items to/from the Global Assembly Cache. However, it has some problems:
- The application is not distributed with the .NET framework.
- Inability to uninstall the assembly if it is installed by an MSI installer.
- Difficult to use if you uninstall the assembly and do not know the fully qualified assembly name (including the PublicToken).
An attempt to uninstall the assembly installed by an MSI will generate an error message like the one below:
D:\temp\aa>gacutil /u "MySDKDll, Version=22.214.171.124,
Culture=neutral, PublicKey Token=da66bde628dcedb8,
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved. Assembly: MySDKDll,
Version=126.96.36.199, Culture=neutral, PublicKeyToken=da66bde 628dcedb8,
Unable to uninstall: assembly is required
by one or more applications Pending references:
SCHEME: <windows_installer />ID: <msi />DESCRIPTION : <windows installer="" />
Number of assemblies uninstalled = 0
Number of failures = 0
There are utilities that can do the job, like GacView, but it is not command-line driven, and therefore can not be used as a part of the installer (apart from licensing issues).
The presented utility can be controlled from a command line. It removes the assemblies even if they are installed by a MSI. In order to remove such an assembly, Registry entries have to be cleared:
The utility identifies the entries in these keys and removes the content.
private void ClearRegKey(string AssemblyShortName, RegistryKey BaseKey)
RegistryKey key = BaseKey.OpenSubKey(@"Software\Microsoft\" +
if (key != null)
string names = key.GetValueNames();
foreach (string Name in names)
string Words = Name.Split(',');
string nn = Words;
string nn2 = Words;
if (AssemblyShortName == nn)
key.SetValue(Name, "", RegistryValueKind.String); key.Close();
How to use the utility
GacInstaller.exe i "C:/Program Files/ABCD/MySDKDll.DLL"
Uninstalling the assembly:
GacInstaller.exe u MySDKDll - just the name
GacInstaller.exe u MySDKDll da66bde628dcedb8 - using name and public token
If installation/uninstallation is unsuccessful, the application form turns red and the error information is written to the log file.
The utility uses the GAC API wrapper created by Junfeng Zhang. The original wrapper code is available here.
The current version is 1.0.0. The most recent version can be downloaded from www.dotnetremoting.com along with other useful components.