Strong Name Assembly (strong name assembly)--give the assembly a strong name

Source: Internet
Author: User




Introduction :

In the previous project development, a file with a suffix of *.snk was seen in the Assembly, and the icon of the file was viewed as a way of protecting copyright within the enterprise.



One, what issues does the strong assembly solve?


1 , uniquely identifies an assembly

2 , the placement assembly is counterfeit and tampered with.

3 , you can deploy to the global assembly cache ( gac:globalassembly Cache ), when the strong-named assembly is not cooked in the GAC later, a strong-named assembly can also be called a shared assembly ( shared Assembly )



two, strong name and GAC

Strong Name:

Defines a rule that distinguishes an assembly not just from a file name, which is a strong name.

GAC :

define a special folder that will recognize this rule and allow files of the same file name to exist, which is the special folder GAC .


third, give the assembly a strong name


Open the VS Developer command prompt tool:





first, let's create a public key private key file, using the Sn-k command:



Then we will find the success of creating lhc.snk under this folder:


Places to be aware of:

1 , each call SN time, the private key created / The key pair files are not the same, not only their own computer each time the generation of different, all other computers generated is not the same.

2 , the name of the file, if it is an individual, can be named after their own name; If the team, the organization of Fire Company, can be named after the organization name.

3 , in most cases, individuals and organizations need only one SNK file, use this when you create a strong name later SNK file. Because the strong-named assembly is signed with the private key of the SNK file, the file must be tightly protected.

the above created lhc.snk it contains both the public key and the private key. The public key can be viewed using the sn.exe , but the private key cannot be viewed.




If you need to see the public key, you can use the SN-P command:




Then use the SN-TP command to view the *.pk file:





Once we have created this public key file, we can use it to identify the uniqueness of the assembly.



Set the signature properties for this assembly in the assembly that you want to set:








After saving and then observing this assembly, you will find one more file:










Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Strong Name Assembly (strong name assembly)--give the assembly a strong name

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.