SA Developer .NET

Strong Name an existing dll / assembly

This post has 1 Reply | 0 Followers

Top 25 Contributor
Male
Posts 182
DoubleJ Cool [H] Posted: Thu, May 31 2007 9:46

We've got a 3rd party DLL that we use (not strong named) and I wanted to add it to the GAC. Alas! Only strong named assemblies are allowed in the GAC. 

 

I've been trying figure this out for almost a week... couldn't find much help on Google Sad, so I thought I'd share.

 

Well, here is my solution (it works... not sure if it's the best way though)

 

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

 

1.       Generate a KeyFile

sn -k keyPair.snk

 

2.       Obtain the MSIL for the provided assembly

ildasm providedAssembly.dll /out:providedAssembly.il

 

3.       Rename/move the original assembly

ren providedAssembly.dll providedAssembly.dll.orig

 

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

ilasm providedAssembly.il /dll /key= keyPair.snk

 

Viola!

 

You now have a strong named assembly.

 

You cannot make anything fool-proof... Fools are too inventive http://dotnet.org.za/doubleJ

Top 10 Contributor
Male
Posts 540
Moderator
DoubleJ:

Well, here is my solution (it works... not sure if it's the best way though)

 

I did some research on this last month.  It is pretty much the only way to do it. 

Page 1 of 1 (2 items) | RSS