GAC (Global Assembly Cache)

Source: Internet
Author: User

Coofucoo. Again became a test...

 

Computer-wide code caching, which stores specially installed assemblies that are shared by many applications on the computer. Applications deployed in the Global Assembly Cache must have a strong name
 
GAC stands for global assembly.
Cache. Its function is to store public assemblies that are used by many programs, such as system. Data and system. Windows. forms.
And so on. In this way, many programs can obtain the Assembly from the GAC without copying all the assembly to the execution directory of the application. For example
If there is no GAC, it is inevitable that the directory of each winform program should be under C: windowsmicrosoft. netframeworkv1.0.3705
Copy a copy of system. Windows. Forms. dll, which is obviously easier to use from the GAC, and also conducive to the upgrade and Version Control of assembly.

In addition to the system default Assembly placed in GAC, such as system. Windows. forms, we can also add our own assembly:
1) create a strong-name Assembly, such as toolbarcomponent. dll.
2) Run gacutil-I toolbarcomponent. dll and add this Assembly to GAC.
3) dynamic loading in the program:
 
System. reflection. Assembly ass = assembly. Load ("toolbarcomponent,
Version = 1.0.934.20434, culture = neutral,
Publickeytoken = 65f45658c8d3167f ");
MessageBox. Show ("is the Assembly loaded from GAC" + ass. globalassemblycache );
 
In the above program, toolbarcomponent is loaded from GAC rather than from the DLL file under the program running directory.
The toolbarcomponent. dll program can also run normally. In addition, parameters in assembly. Load () can be passed through "gacutil
-L.

In addition, the Assembly in GAC must be strong-name. The steps for creating an assembly with strong-name are as follows:
A) Run "Sn-K keypair. SNK" on the command line to create a key file. Sn.exe is also a tool attached to. net.
B) modify the "assemblyinfo. cs" file in vs. Net:
[Assembly: assemblydelaysign (false)]
[Assembly: assemblykeyfile (".../keypair. SNK")]
C) compile the project to get a strong-name assembly.

The following describes GAC in msdn:
1) Assembly Cache Viewer (shfusion. dll)
2) Global Assembly Cache

. NET Framework comes with some GAC-related tools, including:
1)gacutil.exe, a command line tool used to browse, add, and delete an assembly in GAC
2ngen.exe is also a command line tool used to create native image in GAC
3. mscorcfg.msc, an mmc, You can graphically complete the main functions of gacutil.exe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.