Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Referenced assembly does not have a strong name

0.00/5 (No votes)
7 Mar 2012 3  
How to give a strong name to your assembly

Introduction

Sometimes you got an error like following when you reference 3rd party dlls.

Assembly generation failed -- Referenced assembly 'Test' does not have a strong name
Cause is An assembly is not signed with a strong name, the strong name could not be verified, or the strong name would not be valid without the current registry settings of the compute.

The strong name protects clients from unknowingly loading an assembly that has been tampered with. Assemblies without strong names should not be deployed outside of very limited scenarios.

An assembly without a strong name  cannot be loaded into the global assembly cache.

To Fix this, have to follow below steps.

Steps to create strong named assembly

Step 1 : Run visual studio command prompt and go to directory where your DLL located.

  For Example my DLL located in D:/hiren/Test.dll

Step 2 : Now create il file using below command.

  D:/hiren> ildasm /all /out=Test.il Test.dll
  (this command generate code library)

Step 3 : Generate new Key for sign your project.

  D:/hiren> sn -k mykey.snk

Step 4 : Now sign your library using ilasm command.

  D:/hiren> ilasm /dll /key=mykey.snk Test.il

so after this step your assembly contains strong name and signed.

Jjust add reference this new assembly in your project and compile project its running now. 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here