You are not Logged in
Would you like to Login or Register

Today is: 03 September 2010
Check this months hot topics

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 /out:SomeAssembly.il

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 SomeAssembly.il /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
kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Paul Hayman Skype
Author : Paul Hayman
Published : 07 August 2007

Paul is the COO of kwiboo ltd consultant and has more than a decade of 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 (http://www.kwiboo.com/) and is also the creator of GeekZilla.

Comments

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.

December 26, 2007 - 10:07 AM

Dast said:

Very, very helpful.

February 26, 2008 - 5:13 PM

Nagamohan kumar said:

Hai Paul ,

             This is Pretty Cool Thanks 
July 24, 2008 - 7:40 AM

Ralphy P said:

Genius, saved my bacon that one. Thanks.

October 17, 2008 - 4:16 PM

Magaly Vargas said:

Thank you very much

July 29, 2009 - 10:35 AM

Runil said:

THANKS A LOT MAN!!! THIS SAVED MY LIFE!!!

August 28, 2009 - 9:11 AM

Wayne said:

Great stuff - really helped me out!!

October 13, 2009 - 12:30 PM

Dili said:

That saved my day. Awesome posting buddy.

November 19, 2009 - 3:04 PM

Karthi said:

Great Thanks for your valuable information

December 16, 2009 - 10:40 AM

Sunikumar said:

Thanks Saved My time

January 13, 2010 - 12:14 PM

Bhavesh said:

`How Can DO it in ubuntu?

April 14, 2010 - 2: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...

April 20, 2010 - 11:06 AM

Romy said:

You made my day ;)

May 15, 2010 - 2:08 PM

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views