Adding a Strong Name to an existing DLL that you don't have the source to

There are times when you need a DLL to have a strong name; putting it in the GAC for example. With 3rd party DLL's this could be a pain. This is how you do it:

From a VS.NET command prompt, enter the following:

1. Generate a KeyFile

sn -k keyPair.snk

2. Get the MSIL for the assembly

ildasm SomeAssembly.dll /

3. Rename the original assembly, just in case

ren SomeAssembly.dll SomeAssembly.dll.orig

4. Build a new assembly from the MSIL output and your KeyFile

ilasm /dll /key= keyPair.snk

Where do these tools live

If you've not got your framework and sdk paths properly mapped... In framework 2 this is where the command line utilities live:

  • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ilasm.exe
  • C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ildasm.exe
  • C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
Author Paul Hayman

Paul is the COO of kwiboo ltd and has more than 20 years IT consultancy experience. He has consulted for a number of blue chip companies and has been exposed to the folowing sectors: Utilities, Telecommunications, Insurance, Media, Investment Banking, Leisure, Legal, CRM, Pharmaceuticals, Interactive Gaming, Mobile Communications, Online Services.

Paul is the COO and co-founder of kwiboo ( and is also the creator of GeekZilla.


Lex Li said:

What about resources files generated by ildasm? How can I embed them to the signed assembly? It seems that ilasm only accepts one /res.

26/Dec/2007 10:07 AM

Dast said:

Very, very helpful.

26/Feb/2008 17:13 PM

Nagamohan kumar said:

Hai Paul ,

             This is Pretty Cool Thanks 
24/Jul/2008 07:40 AM

Ralphy P said:

Genius, saved my bacon that one. Thanks.

17/Oct/2008 16:16 PM

Magaly Vargas said:

Thank you very much

29/Jul/2009 10:35 AM

Runil said:


28/Aug/2009 09:11 AM

Wayne said:

Great stuff - really helped me out!!

13/Oct/2009 12:30 PM

Dili said:

That saved my day. Awesome posting buddy.

19/Nov/2009 15:04 PM

Karthi said:

Great Thanks for your valuable information

16/Dec/2009 10:40 AM

Sunikumar said:

Thanks Saved My time

13/Jan/2010 12:14 PM

Bhavesh said:

`How Can DO it in ubuntu?

14/Apr/2010 14:39 PM

AndreOliveira said:

I'm having some problems with the last step...

I'm getting this error:

"Assembling 'keyPair.snk' to EXE --> 'Interop.SourceSafeTypeLib.exe'

Source file is ANSI

keyPair.snk(1) : error : Syntax error at token '' in :

*** FAILURE ***"

How can I manage this???

Thanks in advance...

20/Apr/2010 11:06 AM

Romy said:

You made my day

15/May/2010 14:08 PM

Vadim said:

I'm trying to add one of the OpenOffice 3 DLLs to the GAC, and when was using your method I've got "FAILURE" result because of compile errors like: : error -- Cannot compile native/unmanaged method : error -- Local (embedded native) PInvoke method, the resulting PE file is unusable

May be there are some dependencies in that dll.

How can I solve this ?

15/Sep/2010 08:13 AM

sandip said:

Thanks man

U saved me

13/Oct/2010 12:16 PM

soadante said:

Really helpful, thanks man!

05/Jan/2011 15:11 PM

riva said:

Thank you!

02/Mar/2011 02:55 AM

LuizAntonio said:

SomeAssembly.dll This would be the third assembly and SomeAssembly.dll.orig the name of my assembly as Strong Name

I'm waiting and I thank you

11/Mar/2011 23:22 PM

vijay said:

I have one dll in C:, when i was excute the 2 point, i got the error "unable ot open classlibrary1.dll

I am trying to excute in vs cmd prompt

ildasm C:\classlibrary1.dll out\

 please assist me ASAP
18/Mar/2011 13:06 PM

Prabhat said:

Thanks, Very Helpful

30/May/2011 07:23 AM

Prabhat said:


Facing problem when run .EXE that use.tlb file on other system on which .Net framework is not installed.

I would like to ask that to run an application that use .tlb file,we always have .Net Framework on targeted machine.

How to run that application on tageted machine without .Net Framework.

Please suggest.

22/Jun/2011 06:56 AM

Atul Goswami said:

Thanx Man .. It saved my lots of Efforts!!

21/Sep/2011 08:46 AM

W@rfi said:

Thanks for the post. It was very helpful and saved a lot of my time ....

24/Nov/2011 14:09 PM

saritha said:

very helpfull

30/Apr/2012 08:20 AM

HR said:


04/Sep/2012 22:17 PM

Ben said:

You, my friend, are a legend.

21/Sep/2012 05:34 AM

Sadegh said:

Very Very helpful


06/Oct/2012 18:43 PM

Sangeet Ahuja said:

Awesome. Thanks,

10/Oct/2012 01:44 AM

Billy Westbury said:


23/Oct/2012 14:22 PM

Chris said:

Nice post. Very useful.

14/Feb/2013 11:42 AM

Add Comment


Your comment has been received and will be shown once it passes moderation.