How to fix “Referenced assembly does not have a strong name” error?
Sometimes you got an error like following when you reference 3rd party dlls.
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.
For Example my DLL located in D:/ziad/Test.dll
Step 2 : Now create il file using below command.
D:/ziad> ildasm /all /out=Test.il Test.dll
(this command generate code library)
Step 3 : Generate new Key for sign your project.
D:/ziad> sn -k mykey.snk
Step 4 : Now sign your library using ilasm command.
D:/ziad> ilasm /dll /key=mykey.snk Test.il
so after this step your assembly contains strong name and signed.
just add reference this new assembly in your project and compile project its running now.
Note : After running you application , if you faced below error you have to register DLL in GAC(Global Assembley Cache)
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:/ziad/Test.dll
Step 2 : Now create il file using below command.
D:/ziad> ildasm /all /out=Test.il Test.dll
(this command generate code library)
Step 3 : Generate new Key for sign your project.
D:/ziad> sn -k mykey.snk
Step 4 : Now sign your library using ilasm command.
D:/ziad> ilasm /dll /key=mykey.snk Test.il
so after this step your assembly contains strong name and signed.
just add reference this new assembly in your project and compile project its running now.
Note : After running you application , if you faced below error you have to register DLL in GAC(Global Assembley Cache)
No comments:
Post a Comment