HOW TO:從全域組件快取移除組件How to: Remove an Assembly from the Global Assembly Cache

從全域組件快取 (GAC) 移除組件的方式有兩種:There are two ways to remove an assembly from the global assembly cache (GAC):

  • 使用全域組件快取工具 (Gacutil.exe)By using the Global Assembly Cache tool (Gacutil.exe). 若要解除安裝開發和測試期間放在 GAC 中的組件,可使用這個選項。You can use this option to uninstall assemblies that you've placed in the GAC during development and testing.

  • 使用 Windows InstallerBy using Windows Installer. 若要解除安裝測試安裝套件時及針對生產系統所使用的組件,則應該使用這個選項。You should use this option to uninstall assemblies when testing installation packages and for production systems.

使用 Gacutil.exe 移除組件Removing an assembly with Gacutil.exe

  1. 在命令提示字元中輸入下列命令:At the command prompt, type the following command:

    gacutil –u <組件名稱>gacutil –u <assembly name>

    在這個命令中,「組件名稱」是要從全域組件快取移除的組件名稱。In this command, assembly name is the name of the assembly to remove from the global assembly cache.


    您不應該使用 Gacutil.exe 移除生產系統上的組件,因為某個應用程式可能仍需要這個組件。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. 您應該改用 Windows Installer,以維護安裝在 GAC 中之每個組件的參考計數。Instead, you should use the Windows Installer, which maintains a reference count for each assembly it installs in the GAC.

下列範例會從全域組件快取移除名為 hello.dll 的組件。The following example removes an assembly named hello.dll from the global assembly cache.

gacutil -u hello  

使用 Windows Installer 移除組件Removing an assembly with Windows Installer

  1. 從 [控制台] 中的 [程式和功能] 應用程式,選取您要解除安裝的應用程式。From the Programs and Features app in Control Panel, select the app that you want to uninstall. 如果安裝套件將組件放在 GAC 中,Windows Installer 會在其他應用程式未使用這些組件時,將組件移除。If the installation package placed assemblies in the GAC, Windows Installer will remove them if they are not used by another application.


    Windows Installer 會維護安裝在 GAC 中之組件的參考計數。Windows Installer maintains a reference count for assemblies installed in the GAC. 只有在組件的參考計數到達零時 (表示 Windows Installer 套件所安裝的任何應用程式都未使用這個組件),才能從 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