C# 注册DLL 到 GAC 目录

  1. 只有strong name的 DLL 才能被注册到 GAC 中
  2. GAC下的DLL名字不能重复
  3. GAC 的注册工具是 gacutil.exe
  4. “gacuntil.exe”需要管理员权限
  5. 使用示例
    1. 注册DLL到GAC目录
      1. DLL位置在 c:\MyTest\test.dll
      2. 注册命令 gacutil.exe /k c:\MyTest\test.dll
      3. 注册完成后可以在 gac 目录下查看到该 DLL
    2. 卸载注册到GAC目录下DLL
      1. 卸载GAC下DLL 只需要一个DLL名字即可
      2. 卸载命令 gacutil.exe test
      3. 卸载完成后,刚才注册的test.dll就会从gac目录下删除
  6. 具体详细命令 使用 /? 或者 /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

`

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值