C# Language [AssemblyKeyFile]


Example

Whenever we want our assembly to install in GAC then it is must to have a strong name. For strong naming assembly we have to create a public key. To generate the .snk file.

To create a strong name key file

  1. Developers command prompt for VS2015 (with administrator Access)
  2. At the command prompt, type cd C:\Directory_Name and press ENTER.
  3. At the command prompt, type sn -k KeyFileName.snk, and then press ENTER.

once the keyFileName.snk is created at specified directory then give refernce in your project . give AssemblyKeyFileAttribute attribute the path to snk file to generate the key when we build our class library.

Properties -> AssemblyInfo.cs

[assembly: AssemblyKeyFile(@"c:\Directory_Name\KeyFileName.snk")]

Thi will create a strong name assembly after build. After creating your strong name assembly you can then install it in GAC

Happy Coding :)