Roles of snk files and AssemblyInfo. cs files

Source: Internet
Author: User

The snk file is used in .netto store the encrypted or encrypted storage file, and the sn.exe command in .netcan be used to generate the encrypted snk file, such as "sn-k keyPair. snk ".
Snk itself is only used to store asymmetric keys, but it can be used wherever encryption and signature are needed:
Use the snk file to generate a strongly-named assembly so that an assembly can be assigned the full-trust attribute or added to GAC. To generate strong-named assembly in VS. NET, you only need to add the code and compile it in AssemblyInfo. cs:
[Assembly: AssemblyDelaySign (false)]
[Assembly: AssemblyKeyFile ("... \ .. \ keyPair. snk")]
[Assembly: AssemblyKeyName ("")]
Reason for strong-naming Assembly: DLL Hell issues currently occurring in Windows (two different companies may develop assembly with the same name, if you place a set of programs with the same name in the same directory, the Assembly overwrites the Assembly. The Assembly that is finally installed overwrites the previous Assembly, as a result, the application sequence may not run properly ). From this point of view, it is not enough to distinguish a set of programs by name alone. CLR uses a strongly-named assembly to uniquely represent an assembly. A strongly-named Assembly contains four identifiers: name, version number, Language and Culture identifier, and a common/private key pair. Two assembly/two deployment methods :. net supports two types of Assembly: weak naming assembly and strong naming assembly (Note :.. Net Framework does not have a weak naming assembly, just to match the strong naming assembly ). Weak naming assembly and strong naming Assembly are in the same structure. They all adopt the PE file format, including the PE Header, CLR header, metadata, and list table. The difference is that a strongly-named assembly has a publisher's public/private key signature pair, which is used to uniquely identify the publisher of the Assembly. Through the public/private key pair, We can uniquely identify the Assembly, security policy, and Version Policy.
AssemblyInfo. cs is mainly used to set some parameters of the generated assembly-related general information dll file, such
Using System. Reflection;
Using System;
Using System. Runtime. ConstrainedExecution;
Using System. Runtime. CompilerServices;
Using System. Runtime. InteropServices;
// Whether the public language specification (CLS) is met)
[Assembly: CLSCompliant (true)]
// Control the accessibility of all types of COM in the dataset
[Assembly: ComVisible (false)]
// Reliable agreement between the author of the Code and the developers of the Code
[Assembly: ReliabilityContract (Consistency. WillNotCorruptState, Cer. MayFail)]
// For general information about the assembly, use the following attribute set
// Control. You can modify these attribute values.
// Information associated with the Assembly.
[Assembly: AssemblyTitle ("TestPetShop. SQLServerDAL")]
[Assembly: AssemblyDescription ("T test PetShop4.0")]
[Assembly: AssemblyConfiguration ("")]
[Assembly: AssemblyCompany ("CCP")]
[Assembly: AssemblyProduct ("TestPetShop. SQLServerDAL")]
[Assembly: AssemblyCopyright ("Copyright (C) CCP 2007")]
[Assembly: AssemblyTrademark ("")]
[Assembly: AssemblyCulture ("")]
// Set ComVisible to false to make the type in this Assembly
// The COM component is invisible. If you need to access the types in this Assembly from COM,
// Set the ComVisible attribute of this type to true.
[Assembly: ComVisible (false)]
// If this project is made public to COM, the following GUID is used for the ID of the Type Library
[Assembly: Guid ("dc8b813c-f361-476f-8cf1-8fab3d57ced7")]
// The Assembly version information consists of the following four values:
//
// Main version
// Version
// Internal version number
// Revision No.
//
[Assembly: AssemblyVersion ("1.0.0.0")]
[Assembly: AssemblyFileVersion ("1.0.0.0")]

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.