A assembly typically includes 4 custom properties, which are used to identify assemblies, which are file names (non-extensions), version numbers, regional identifiers, and public key tags, such as:
"Hello, Version = 1.0.0.0, Culture = neutral, publickeyToken = 9EBD24CC40FF211FD"
The publickeyToken is the 64-bit scatter value of the public key. You can uniquely identify the assembly. The assembly of the public key tag is called a strong name assembly. Strong Name assembly can be tamperped; can be installed into the GAC, for multiple programs Set the sharing; you can also implement version strategies (different versions of strong name assemblies are considered different assemblies). The assembly of public key markers can only exist in the directory of the referenced assembly and subdirectory, and cannot implement version policies (reference numerals to ignore the version number).
The public key can be generated by the sn.exe command provided by the .NET SDK, and the method is:
Sn.exe -k zhang.snk
This gives a public / private key file named ZHANG.SNK, put it from a directory, such as g: /, then create a strong name assembly, just add the following in the source code Custom properties:
[assembly: assemblykeyKeyfile (@ "g: /zhang.snk")]
Below is a Hello.cs file, an example of creating a strong name assembly
Using system;
Using system.reflection;
[Assembly: AssemblyVersion ("1.0.0.0")] // Contest version
[assemblycultureattribute (")] // area (empty, means language neutral)
[Assembly: askEMBLYKEYFILE (@ "g: /zhang.snk")] // public private key pair
Namespace Zhang.Study
{
Public Class Hello
{
Public Hello ()
{
Console.writeline ("Class Hello Version 1.0");
}
Public void sayhello ()
{
Console.writeline ("Hello, C #!");
}
}
}
# Hello.RSP /out:./bin/hello.dll / target: library hello.cs #end
Finally compile the source code: csc.exe hello.rsp, get a strong name assembly hello.dll, open this assembly using Reflector.exe, you can see this description: name: hello, version = 1.0.0.0, Culture = neutral, publickeyToken = 9EBD24CC40FF211FD.
Reference book: "Microsoft .NET Framework program" JEFFERY RICHTER "Don Box, Chris Sells" Don Box, Chris Sells "MSDN"