logo

Referenced assembly does not have a strong name? (C# .NET)
mark Pauly posted at Monday, December 11, 2006 4: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

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0
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 Monday, December 11, 2006 5:23 AM

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

check out here

http://support.microsoft.com/kb/313666

http://msdn2.microsoft.com/en-us/library/ms379563(vs.80).aspx

 

Reply    Reply Using Power Editor
K Praveen Kumar Reddy MCPDEA.
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

strong name
sundar k provided a rated reply to mark Pauly on Monday, December 11, 2006 6: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,

http://aspalliance.com/394_Installing_an_Assembly_in_GAC

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

Thanks again
mark Pauly replied to sundar k on Monday, December 11, 2006 8:03 AM

Venkatesh.

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.

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0


Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Ask Question In Live Forum

If you have an OpenID and do not want to become a member of the EggHeadCafe forum, you can also sign on to Chat Chaos and post your question to our real time Silverlight chat application.
Ask Question In Chat Chaos










  $1000 Contest    [)ia6l0 iii - $228  |  Jonathan VH - $161  |  Huggy Bear - $135  |  F Cali - $95  |  egg egg - $94  |  more Advertise  |  Privacy  |   (c) 2010