How to give strong name to DLL and how to install DLL in GAC in dotnet

Introduction:In this example i will explain how to give  strong name to DLL and how to install      DLL in GAC

Steps for Giving  strong name to DLL:

     1.Open .net Command prompt
     2.Go to the folder containing DLL.
     3.Type sn  -k  ClassLibrary1.snk , you can use any file name instead of test.This will                 create ClassLibrary1.snk file in that folder.
    4. Open the assemblyinfo.cs file of project. 
    5. Type file path in this tag
    [assembly: AssemblyKeyFile("E:\\sai\\ClassLibrary1\\ClassLibrary1                                   \\bin\\Debug            \\ClassLibrary1.snk")]
    6.Build application, finally your strongname created for your DLL.

   Example
    Open .net command prompt
    Go to the folder containing DLL.



Now you Type    sn  -k  ClassLibrary1.snk

 

The above command create  ClassLibrary.snk file in E:\sai\ClassLibrary1\ClassLibrary1 \bin\Debug folder. 

     Open the AssemblyInfo.cs file(In properties section)of project
  • After assembly version tags Type  path  of snk file in following attribue.
[assembly: AssemblyKeyFile("E:\\sai\\ClassLibrary1\\ClassLibrary1\\bin\\Debug\\ClassLibrary1.snk")]


Now you build the Classlibrary .
For your Library now  strong name  has created.

No comments: