C# .NET - Referenced assembly does not have a strong name?

Asked By mark Pauly on 11-Dec-06 04:39 AM

I have just added a new assembly to my solution, I decided thta it would be a good idea to create a separte assembly to do things which were common the others. The new assembly compiles ok, but when I add this as a reference to another project, I get the Referenced Assembly 'AssemblyName' does not have a strong name. Any ideas what is going on here?

Many thanks

PRB: "Assembly Generation Failed" Error Message When You Try to Build a Managed DLL Without a Strong Name

K Pravin Kumar Reddy replied to mark Pauly on 11-Dec-06 05:23 AM

PRB: "Assembly Generation Failed" Error Message When You Try to Build a Managed DLL Without a Strong Name

check out here



strong name - sundar k replied to mark Pauly on 11-Dec-06 06:39 AM

Have you created a Strong name for your Assembly and moved the assembly to GAC so that it's made public and can be referenced across applications?

After creating an assembly and before registering it to the Global Assembly Cache the first thing that is required is to assign a strong name to the assembly. What is a strong name? Well! a strong name is basically assigned to an assembly or a component to distinguish it from other assemblies and components existing in the GAC. A strong name consists of an assembly identity (name, version, etc.), public key and a digital signature.

The Global Assembly Cache is used to share assemblies throughout applications.

For example, to create a strong name for an assembly named as sample.dll, you would write on the command prompt.

sn -k sample.snk

This would generate a strong name key pair and store it in a file named as sample.snk. The extension of the file can be anything, but mostly .snk is used as a convention. The -k option here is for creating a strong name key pair. There are other options also available which you could search for in MSDN.

After generating the strong name key pair file, it is required to associate this file with our assembly, for doing that you have to add the following lines in the code of your assembly.

Imports System.Reflection

<assembly: AssemblyKeyFile("sample.snk")>

Note here that the information regarding the file containing the strong name key pair is placed in the code file before the namespace declaration. Also you are required to import the System.Reflection namespace in order for the statement to work, otherwise the compiler would be showing you an error stating that it does not recognize the <assembly: AssemblyKeyFile("sample.snk")> statement.

After compiling the assembly with the statements, containing the strong name information being added to it, you now have to place the assembly into the GAC. You can either do it manually by simply copying and pasting the assembly into the GAC, which is located at c:\winnt\assembly;

or use gacutil ,

gacutil /i sample.dll

please refer to below link for more info,


Thanks again - mark Pauly replied to sundar k on 11-Dec-06 08:03 AM


It seems that the other assemblies had each got snk files associated with them.

By right clicking on the Project and selecting properties, the assembly has the 'Sign the assembly' box checked and the strong name key file was there.

Looks like the previous developer who has a more in depth knowledge of .NET development than me has forgotten to document this small thing!

Thanks to you guys here at egghead, I am discovering new things every day so I was able to see this.

Michal replied to mark Pauly on 05-Aug-11 03:04 AM
You can always try to disassembly dlls and then compile il code with signing. More information you can find under following http://www.jankowskimichal.pl/en/2011/08/assembly-generation-failed-referenced-assembly-does-not-have-a-strong-name/.