Click here to Skip to main content
Click here to Skip to main content

Referenced assembly does not have a strong name

By , 7 Mar 2012
 

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Hiren Khirsaria
Software Developer (Senior)
India India
has 4 + Total Experience in Microsoft.Net Environment.
 
2 + year Excperience in .Net Development with C# and SQL Server 2005/2008.
 
2 + Experience in WPF/Silverlight.
 
Current area of Development in Mono for Android (Xamarin), Silverlight/ WPF and Windows Phone 7 Application.
 
Follow him on : http://hirenkhirsaria.blogspot.com/

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
AnswerThanks I got my answer.memberkrunal298416-May-13 2:34 
Thank you. your post was really helping.
QuestionError in the last sentencememberd.chang30-Apr-13 5:20 
When I execute:
ilasm /dll /key=mykey.snk Test.il
get the following error:
Microsoft (R) .NET Framework IL Assembler. Version 4.0.30319.17929
Copyright (c) Microsoft Corporation. All rights reserved.
Assembling 'Test.il' to DLL --> 'Test.dll'
Source file is ANSI
 
Test.il(5) : error : syntax error at token 'error' in: error : File 'Test.dll' n
ot found or not a PE file
 
***** FAILURE *****

What's wrong???
AnswerRe: Error in the last sentencememberHiren Khirsaria30-Apr-13 19:22 
This error seems to be Test.dll not found, have you first complied you dll ?
 
please first build your assembly and follow steps one by one
 
please let me know still you getting error
 

Thanks,
Hiren
QuestionAnother waymembergbsistemas19-Aug-12 7:44 
Hi, first of all thank for your time on writing this. Another way you can do this is by going to property panel of the project, then to signing tab and add a signature to your project.
 
Regards!
Gabriel Brancolini

AnswerRe: Another waymemberHiren Khirsaria19-Aug-12 22:07 
Thanks for your feedback
QuestionThoughtsmemberPIEBALDconsult7-Mar-12 7:57 
The strong name should be compiled into the Assembly, not added after the fact. In Visual Studio you can add the key file to your project. At the command line you can use the /keyfile:<file> switch.
AnswerRe: ThoughtsmemberHiren Khirsaria9-Mar-12 0:36 
have you got any error like "Assembly generation failed -- Referenced assembly 'Test.Data' does not have a strong name"
when you add 3rd party dll
 
try with some 3rd party dll which have strong name and if you try to add reference at that time you will get errors like this.
 
to solve thi error you must have to follow my given steps.
GeneralRe: ThoughtsmemberPIEBALDconsult9-Mar-12 2:18 
Not that I recall. Altering a third-party DLL sounds like a bad idea.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 7 Mar 2012
Article Copyright 2012 by Hiren Khirsaria
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid