Coder Perfect

How to resolve the error “The referenced assembly does not have a strong name”


In my Visual Studio 2005 project, I’ve inserted a poorly named assembly (which is strongly named). Now I’m receiving the following error:

Is it necessary for me to sign this third-party agreement?

Asked by ng5000

Solution #1

You have two options to avoid making this mistake:

In.NET-fu: Signing an Unsigned Assembly, you’ll find instructions for signing third-party assemblies (Without Delay Signing).

To sign a thirp-party, the key premise is to

Unless your third-party assembly (A.dll) accesses another library (B.dll) that must also be signed, the steps above will work correctly. You can use the commands above to deconstruct, rebuild, and sign both A.dll and B.dll, but loading B.dll will fail at runtime since A.dll was constructed with a reference to an unsigned version of B.dll.

The issue can be resolved by patching the IL file created in step 1 above. The public key token of B.dll must be added to the reference. This token is obtained by dialing

sn -Tp B.dll 

which will produce the following result:

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.33440
Copyright (c) Microsoft Corporation.  All rights reserved.

Public key (hash algorithm: sha1):

Public key token is a8a7ed7203d87bc9

The public key token is found on the last line. Then look for a reference to B.dll in the IL of A.dll and add the token as follows:

.assembly extern /*23000003*/ MyAssemblyName
  .publickeytoken = (A8 A7 ED 72 03 D8 7B C9 )                         
  .ver 10:0:0:0

Answered by Dirk Vollmar

Solution #2

Look for the.snk file in the project file that is utilizing the project that does not “have a strong name key” (.StrongNameKey).

In Windows Explorer, navigate to this file (just so that you know where it is).

Return to Visual Studio and work on the project that doesn’t have a “strong name key.”

That ought to suffice. This fixed a problem I was having with one project including a form within another project in the same solution.

I hope this information is useful.

Answered by MrOli3000

Solution #3

I was looking for a solution to the similar issue and found that unticking “Sign the assembly” worked for me:

(As you can see, the screenshot is from Visual Studio 2010, but it may be useful to someone.)

Answered by Mars Robertson

Solution #4

I’ve created a tool that will automatically strong-name sign assemblies for which you don’t have the source code or for which you’ve abandoned a project. It employs many of the approaches described in the responses in a straightforward manner, with none of the defects or downsides associated with existing tools or out-of-date instructions.

Strong-Name Signer for.NET Assembly

I hope this is useful to anyone who has to sign a third-party assembly without having to go through a lot of hoops.

Answered by BrutalDev

Solution #5

If your assembly is also unsigned, you can use unsigned assemblies.

Answered by Alexandr Nikitin

Post is based on