How to create strongly type key in Visual Studio
Sudarshan Rathod
.NET | Azure PAAS | MS SQL | DataDog | Elastic search | Web API | ReactJs | SharePoint dev | JavaScript| JQuery
Following are the simple steps to generate .snk file and strongly type key:
- Create any normal project/class library or any existing project
- Go to "All programs >Visual Studio (any version) 2015 > Visual Studio Tools > Developer Command Prompt for Visual Studio right click run as administration
- Write command to generate .snk file or "Strong Name Key" i.e. sn -k E:\NameForYourStrongKey.snk
- Now goto opened project goto AsseblyInfo.cs double click and add attribute inside the file [assembly: AssemblyKeyFile("E:\\NameForYourStrongKey.snk")]
- Now Save and build your project and see the output window and copy the path of generated dll.
- Go to same command prompt and paste that path after cd "copied path without dll"
- Now use command "sn -T dllName.dll" It will generate Public Key Token
- Now to install the assembly in the cache type the use command in the command promt: gacutil –i "Name of the Class Library"
- Now the Assembly is successfully installed in your system. If you want to see that you can see that in the location “C:\Windows\Microsoft.NET\assembly\GAC_MSIL and your projectName”