Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Tuesday, April 10, 2007

Creating Shared Assembly or GAC Assembly and accessing

Creating an assembly key file
The steps involved in adding an assembly to the GAC is not as simple as adding the assembly to a web application. Since all applications can access this library, some security precautions have been taken by Microsoft to ensure uniqueness, version protection, and code integrity. This is achieved by creating a strong name for your new assembly. A Strong Name consists of the assembly indentity and also a public key and digital signature.
To create a strong name, you use the syntax:

sn -k StrongNameFile.snk
Adding StrongNameFile.snk entry and modifying the version in AssemblyInfo.cs
[assembly: AssemblyVersion("")]
[assembly: AssemblyKeyFile("c:\\DuttLibrary.snk")]

Adding your assembly to your GAC
gacutil /i AssemblyFileName.dll

Adding your assembly machine.config
 < assembly="AssemblyFileName, Version=, Culture=neutral, PublicKeyToken=5edf592a9c40680c">

Using Shared Assembly

<%@Import Namespace="Devhood"%>

Post a Comment