Web
Site
Register
::
Login
Forums
February 06, 2012
Forums
Unanswered
Active Topics
Forums
Search
Forums
>
Programming - Dotnet / Delphi
>
General DotNet
Subject: Creating and using Strong Name
Prev
Next
Add Reply
Author
Messages
Oldest First
Newest First
Don
New Member
Posts:20
02/04/2005 12:10 PM
Quote
Reply
Assemblies can be assigned a cryptographic signature, called a strong name, which provides name uniqueness for the assembly and prevents someone from taking over the name of your assembly (name spoofing). If you are deploying an assembly that will be shared among many applications on the same machine, it must have a strong name. Even if you only use the assembly within your application, using a strong name ensures that the correct version of the assembly gets loaded
The first step in building an assembly with a strong name is to obtain a cryptographic key pair. The .NET Framework SDK includes a Strong Name tool (Sn.exe) that can be used to generate a key pair. The key pair that is generated by the Strong Name tool can be kept in a file or you can store it in your local machine's Crytographic Service Provider (CSP). The following command uses the Strong Name tool to generate a new key pair and store it in a file called TestKey.snk:
sn -k Testkey.snk
Once you have obtained the key pair, you need to add the proper custom attribute to your source in order for the compiler to emit the assembly with a strong name. Choosing the correct attribute depends on whether the key pair used for the signing is contained in a file or in a key container within the CSP. For keys stored in a file, use System.Reflection.AssemblyKeyFileAttribute. For keys stored in the CSP use System.Reflection.AssemblyKeyNameAttribute.
The following example uses AssemblyKeyFileAttribute to specify the name of the file containing the key pair. The assembly level attributes must be the first statements in the file.
using System;
using System.Reflection;
[assembly:AssemblyKeyFileAttribute('TestKey.snk')]
Add Reply
FAQ
--General FAQ
Experiences
--Comments, complaints about anything
--Customer Service
Music
--New Music Notifications
--General Music
--St. Alphonzo's 2010
--St. Alphonzo's 2009
--St. Alphonzo's 2008
--St. Alphonzo's 2007
--St. Alphonzo's 2006
--St. Alphonzo's 2005
Programming - Dotnet / Delphi
--General DotNet
--.Net Framework Code Snippets
--ASP.NET Tips and Snippets
--Compact Framework
--Compact Framework Code Snippets
--Delphi
Forums
>
Programming - Dotnet / Delphi
>
General DotNet
> Creating and using Strong Name
Quick Reply
Username:
Subject:
Body:
Submit
Home
Forums
Bluto Band
Music
Music Videos
Photographs
Download
Liquid Mix
ERG 40
Favorite Links
Home
|
Forums
|
Bluto Band
|
Music
|
Music Videos
|
Photographs
|
Download
|
Liquid Mix
|
ERG 40
|
Favorite Links