- 只有strong name的 DLL 才能被注册到 GAC 中
- GAC下的DLL名字不能重复
- GAC 的注册工具是 gacutil.exe
- “gacuntil.exe”需要管理员权限
- 使用示例
- 注册DLL到GAC目录
- DLL位置在 c:\MyTest\test.dll
- 注册命令 gacutil.exe /k c:\MyTest\test.dll
- 注册完成后可以在 gac 目录下查看到该 DLL
- 卸载注册到GAC目录下DLL
- 卸载GAC下DLL 只需要一个DLL名字即可
- 卸载命令 gacutil.exe test
- 卸载完成后,刚才注册的test.dll就会从gac目录下删除
- 注册DLL到GAC目录
- 具体详细命令 使用 /? 或者 /h 查看帮助文档
c:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>gacuti
l.exe /h
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: Gacutil <command> [ <options> ]
Commands:
/i <assembly_path> [ /r <...> ] [ /f ]
Installs an assembly to the global assembly cache. <assembly_path> is the
name of the file that contains the assembly manifest.
Example: /i myDll.dll /r FILEPATH c:\projects\myapp.exe "My App"
/il <assembly_path_list_file> [ /r <...> ] [ /f ]
Installs one or more assemblies to the global assembly cache.
<assembly_list_file> is the path to a text file that contains a list of
assembly manifest file paths. Individual paths in the text file must be
separated by CR/LF.
Example: /il MyAssemblyList.txt /r FILEPATH c:\projects\myapp.exe "My App"
myAssemblyList.txt content:
myAsm1.dll
myAsm2.dll
/u <assembly_display_name> [ /r <...> ]
Uninstalls an assembly. <assembly_name> is the name of the assembly
(partial or fully qualified) to remove from the Global Assembly Cache.
If a partial name is specified all matching assemblies will be uninstalled.
Example:
/u myDll,Version=1.1.0.0,Culture=en,PublicKeyToken=874e23ab874e23ab
/r FILEPATH c:\projects\myapp.exe "My App"
/uf <assembly_name>
Forces uninstall of an assembly by removing all traced references.
<assembly_name> is the full name of the assembly to remove.
Assembly will be removed unless referenced by Windows Installer.
!! Warning: use the /uf command with care as applications may fail to run !!
Example: /uf myDll,Version=1.1.0.0,Culture=en,PublicKeyToken=874e23ab874e23a
b
/ul <assembly_display_name_list_file> [ /r <...> ]
Uninstalls one or more assemblies from the global assembly cache.
<assembly_list_file> is the path to a text file that contains a list of
assembly names. Individual names in the text file must be
separated by CR/LF.
Example: /ul myAssemblyList.txt/r FILEPATH c:\projects\myapp.exe "My App"
myAssemblyList.txt content:
myDll,Version=1.1.0.0,Culture=en,PublicKeyToken=874e23ab874e23ab
myDll2,Version=1.1.0.0,Culture=en,PublicKeyToken=874e23ab874e23ab
/l [ <assembly_name> ]
Lists the contents of the global assembly cache. When the optional
<assembly_name> parameter is specified only matching assemblies are listed.
/lr [ <assembly_name> ]
Lists the contents of the global assembly cache including traced reference
information. When the optional <assembly_name> parameter is specified only
matching assemblies are listed.
/cdl
Deletes the contents of the download cache
/ldl
Lists the contents of the download cache
/?
Displays a detailed help screen
Old command syntax:
/if <assembly_path>
equivalent to /i <assembly_path> /f
/ir <assembly_path> <reference_scheme> <reference_id> <description>
equivalent to /i <assembly_path> /r <...>
/ur <assembly_name> <reference_scheme> <reference_id> <description>
equivalent to /u <assembly_path> /r <...>
Options:
/r <reference_scheme> <reference_id> <description>
Specifies a traced reference to install (/i, /il) or uninstall (/u, /ul).
<reference_scheme> is the type of the reference being added
(UNINSTALL_KEY, FILEPATH or OPAQUE).
<reference_id> is the identifier of the referencing application,
depending on the <reference_scheme>
<description> is a friendly description of the referencing application.
Example: /r FILEPATH c:\projects\myapp.exe "My App"
/f
Forces reinstall of an assembly regardless of any existing assembly with
the same assembly name.
/nologo
Suppresses display of the logo banner
/silent
Suppresses display of all output
`