Signing a Strong Key to an existing DLL that you don’t have its source code

If you tried to build a SharePoint solution that has a reference to DLL file that was not signed with strong key, you will get the following error

DLL referenced file not had Strong Key

Solution:

To set a strong key for a DLL file that you don’t have its source code follow the mentioned steps below:

  • Open “Visual Studio Command Prompt” from Start Menu.

vs-command-prompt.png

  • Drop the dll file in a local temp folder in drive C:\ .
  • Navigate to your DLL Path file by Typing  cd\ to go to the Root C:\
  • Type cd then Tap Button to navigate to your specific temp folder .
  • Generate the Key file.
sn -k Skey.snk
  • Get the MSIL for the assembly.
ildasm Microsoft.ApplicationBlocks.Data.dll /out:Microsoft.ApplicationBlocks.Data.il
  • Rename the original assembly, just in case.
ren Microsoft.ApplicationBlocks.Data.dll Microsoft.ApplicationBlocks.Data.dll.orig

VSCommand

  • Build a new assembly from the MSIL output and your KeyFile.
ilasm Microsoft.ApplicationBlocks.Data.il /dll /key=Skey.snk

signing DLL file

Now the DLL file should be signed with a strong key.

Note: Don't forget to add your signing file in bin folder 
for SharePoint solution "C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin"

Enjoy 🙂

See also Security Exception in SharePoint Visual WebPart

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s