What is a Strong Name?

A strong name consists of the assembly's identity — its simple text name, version number, and culture information (if provided) — plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make up the assembly), using the corresponding private key. Assemblies with the same strong name are expected to be identical.
Strong names guarantee name uniqueness by relying on unique key pairs. No one can generate the same assembly name that you can, because an assembly generated with one private key has a different name than an assembly generated with another private key.
When you reference a strong-named assembly, you expect to get certain benefits, such as versioning and naming protection. If the strong-named assembly then references an assembly with a simple name, which does not have these benefits, you lose the benefits you would derive from using a strong-named assembly and revert to DLL conflicts. Therefore, strong-named assemblies can only reference other strong-named assemblies.
There are two ways to sign an assembly with a strong name:
1. Using the Assembly Linker (Al.exe) provided by the .NET Framework SDK.
2. Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, depending on where the key file to be used is located.
To create and sign an assembly with a strong name using the Assembly Linker, at the command prompt, type the following command:
al /out: /keyfile:
In this command, assembly name is the name of the assembly to sign with a strong name, module name is the name of the code module used to create the assembly, and file name is the name of the container or file that contains the key pair.
The following example signs the assembly MyAssembly.dll with a strong name using the key file sgKey.snk.
al /out:MyAssembly.dll MyModule.netmodule /keyfile:sgKey.snk
To sign an assembly with a strong name using attributes
In a code module, add the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, specifying the name of the file or container that contains the key pair to use when signing the assembly with a strong name.
The following code example uses the AssemblyKeyFileAttribute with a key file called sgKey.snk.
[Visual Basic]
<Assembly:AssemblyKeyFileAttribute("sgKey.snk")>
[C#]
[assembly:AssemblyKeyFileAttribute(@"....sgKey.snk")]

Showing Answers 1 - 1 of 1 Answers

samiksc

  • Jan 13th, 2006
 

A strong name is a way to ensure that a shared assembly's name does not conflict with another shared assembly.

A strong name contains assembly name, a public key and a private key.

For installing an assembly into GAC you need to give it a strong name. First generate a key pair using 'sn.exe' command line utility and write the key file name as AssemblyKeyFileAttribute in a code file of the assembly.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions