articles

Home / DeveloperSection / Articles / Strong name and gacutil command in .Net

Strong name and gacutil command in .Net

AVADHESH PATEL14202 09-Jul-2012
Strong name:

Strong Name is similar to GUID (It is supposed to be unique in space and time). In COM components, Strong name is only needed when we need to deploy assembly in GAC. Strong names help GAC to differentiate between two versions. Strong names use public key cryptography (PKC) to ensure that no one can spoof it. PKC use public key and private key concept. Following are the step to generate a strong name and sign an assembly:

gacutil command:

The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache.

Gacutil.exe is considered to be a development tool. Because of this it is only contained in the .NET SDK but not in the regular redistributable. Visual Studio comes with the SDK, so all Visual Studio users have it installed.

Using strong name and gacutil command:

Step1:Go to “Microsoft Visual Studio 2010” >>Visual Studio Tool>> Visual Studio Command prompt. This wills popup the command prompt for you.

 

Strong name and gacutil command in .Net

Step2:After the command prompt run the strong tool from there

D:\>cd avi

D:\avi>sn –k key.snk

Here k: the key specifies that we want to generate the key.

key.snk: This file contains the key that is generated by the sn tool

 

Strong name and gacutil command in .Net

Note- Microsoft use symmetric algorithm, RSA2

Step3: Attached the key

using System;
using System.Reflection;
[assembly:AssemblyKeyFile("key.snk")]
public class show
{
    public string show_employee()
    {
        return "Hello...";
    }
}

 Write above code on notepad and save it, where key.snk saved. Then make DLL like

Strong name and gacutil command in .Net

Step4:Mapped DLL in Assembly folder

Strong name and gacutil command in .Net

Step5: Write code on notepad and make EXE file in different folder and access show.dll file 

using System;
public class check
{
    public static void Main()
    {
       show s = new show();
       Console.WriteLine(s.show_employee());
    }
}

 

Strong name and gacutil command in .Net

 Step6: execute check exe….

Strong name and gacutil command in .Net


Updated 07-Sep-2019
Avadhesh Kumar Patel District Project Manager - Aligarh 14 months work experience in Panchayati Raj Department Sector as District Project Manager & 12 months work experience in IT Sector as Software Engineer. :-)

Leave Comment

Comments

Liked By