Global Assembly Cache (GAC)
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
Yes, all the assemblies in GAC will be stored in the system directory "% winroot %/assembly. One of the advantages of putting it in the system directory is that the system administrator can control assembly access through user permissions.
About GAC itself, the above quoted paragraph is exactly the definition of GAC in msdn. 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 from C:/Windows/microsoft.net/framework
/V1.0.3705 copy a copy of system. Windows. Forms. dll, which is obviously easier to use from the GAC, but also conducive to the Assembly
Upgrade and version control.
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.