What
is the purpose of Strong Name in COM Components of .NET?
Strong names
in COM components are used to provide identity for an assembly when deployed
in global assembly cache.
The same assembly can have multiple versions of it. To identify each assembly
in unique way, you define and use strong names. Characteristics of strong
names are mentioned below:
" Strong name provides unique name for each version of the assembly
by using public key cryptography which uses both public key and private
key pairs.
" Strong name ensures that the assembly version is reliable and it
is published by the same publisher who created this assembly.
" Strong name ensures better integrity using the digital signatures
and the related certificates.
" Strong name of an assembly encompasses a text, version number,
public key and the digital signature used to sign the certificate.
You can generate
a strong name by following the steps mentioned below:
" In the menu, choose Microsoft Visual Studio <Version Number>
" Navigate to Visual Studio Tools and select Visual Studio Command
Prompt
" In the command prompt, run sn.exe using the following command:
sn.exe -k "c:\sample.snk"
" If the executable runs successfully, you will receive the message
"Key pair written to c:\sample.snk"
" Now the sample.snk is successfully generated and you can try to
read it in notepad but it will not be in human readable form
" Next step you have to perform is to sign your project with this
sample.snk file
" In your Microsoft Development Environment, click on Project menu
and click on the properties for example ClassLibrary1 Properties in the
menu
" In the page that appears, select the radio button corresponding
to "Use a key file" entry.
" In the text box associated with it, browse and select the sample.snk
file
" Now the assembly pertaining to ClassLibrary1 is signed with the
strong name generated in sample.snk