Thursday, October 3, 2013

The Best way to create a Strong named dll is as follows.

creating a strong named dll using the visual command prompt.

First open you Visual studio command prompt.

Start->All Programs -> VisualStudio 201X->Visual Studio Tools->Command Prompt.

It defaults you to a location

C:\ProgramFiles(X86)\MicrosoftVisualStudio10.0\VC>

You should navigate to that location using windows.

Find the folder VC and paste  your DLL and strong named key(if you have one) at this location.

always back up your dll file.

1. You need to either generate a strong  name key or should have  strong named key with you.

1. Generate a KeyFile

sn -k keyPair.snk 
(if you already have strong named key , Ignore this step).
This is your strong named key.
microsft generates this key uniquely , so dont worry abt it.


2. Get the MSIL for the assembly

ildasm YourDLL.dll /out:YourDLL.il

3. Rename the original assembly, just in case

ren YourDLL.dll YourDLL.dll.orig

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

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

You will see your dll updated (timestamp will change).

In addition to the original dll ,  you will also see YOURDLL.IL and YOURDLL.RES files in the folder.

you dont need these ones , once your strong named key is generated.


No comments: