C # Assembly generation 11, Global Assembly Cache

Source: Internet
Author: User

The Global Assembly Cache (GAC: Global Assembly Cache) is used to store strongly-named assemblies that may be used for multiple times. When the main program needs to load the assembly, it first chooses to go to the Global Assembly Cache to find the required assembly.

 

Why is Global Assembly Cache required?
Assume that program a references assembly B, and program C also references assembly B. In this case, it is wise to put assembly B in a Global Assembly cache.

 

□Use global cache assembly

→ Delete All DLL and exe files in the as folder of drive F
→ Compile cow. cs into an assembly

→ Store the created farm. dll in the global assembly cache.

The error message is that a non-strong-name assembly cannot be saved to the Global Assembly Cache.
→ Re-compile cow. cs. Use the key this time.

→ Store farm. dll in the Global Assembly Cache again

If you want to extract a strong-name Assembly from the global cache: gacutil-u farm
→ Compile mainclass. cs into an executable file and reference farm. dll

→ Open mainclass. CS in notepad, modify as follows, and save

using System;
class MainClass
{
    static void Main()
    {
        Cow.Moo();
        Cow.Moo();
        Cow.Moo();
    }
}

→ Compile mainclass. CS again to reference the farm. dll that is already in the global assembly cache.

→ Delete farm. dll from the as folder because it has been stored in the Global Assembly Cache

Then run mainclass.exeand anothermainclass.exe again.

It indicates that farm. dll is already in the global assembly cache.

 

□Where is the global cache assembly?

In the "C: \ WINDOWS \ microsoft. Net \ Assembly \ gac_msil \ farm \ v4.0 _ 3.3.3.3 _ 863de8402b3a9978" folder

 

Summary:
○ When an assembly may be referenced multiple times, you can consider putting the Assembly into the global assembly cache.
○ Custom assembly and. Net default assembly are all placed in the Global Assembly Cache folder "C: \ WINDOWS \ Microsoft. NET \ Assembly \ gac_msil"
○ C # The Compiler first takes priority in the global assembly cache to find the Assembly

 

C # Assembly generation 11, Global Assembly Cache

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.