Assembly generation failed -- Referenced assembly does not have a strong name

Last post 04-24-2009 7:39 AM by purkar rahul. 8 replies.

Sort Posts:

  • Assembly generation failed -- Referenced assembly does not have a strong name

    01-05-2007, 7:29 AM
    • Member
      point Member
    • steven.miles
    • Member since 01-05-2007, 12:03 PM
    • Posts 2

    Hi,

    I've attempted to migrate a VS2005 "Web Site Project" to "Web Application Project". I overcome all issues except 1. When i try to build my new project it compains that a referenced assembly isn't strong named. Unfortunatley this is a third party .NET assembly so it is not built as part of my solution. Both new and old web projects are instructed to be signed in the assemblyinfo.cs the old web site project compiles and publishes fine and the new one doesn't. I've read some pages that suggest i can sign my precompiled(3rd party) assembly but haven't found anything that suggests how this is done. Ultimatley i have 2 questions.

    1. What is the difference between "Site" and "Application" projects that makes this a problem for one and not the other?

    2. How do i get my new application project to build Smile

    Thanks.

    Steve.

     

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    01-05-2007, 9:22 AM
    • Contributor
      4,773 point Contributor
    • mkamoski
    • Member since 07-04-2002, 8:05 PM
    • ZULU-0500
    • Posts 1,299
    steven.miles:

    Hi,

    I've attempted to migrate a VS2005 "Web Site Project" to "Web Application Project". I overcome all issues except 1. When i try to build my new project it compains that a referenced assembly isn't strong named. Unfortunatley this is a third party .NET assembly so it is not built as part of my solution. Both new and old web projects are instructed to be signed in the assemblyinfo.cs the old web site project compiles and publishes fine and the new one doesn't. I've read some pages that suggest i can sign my precompiled(3rd party) assembly but haven't found anything that suggests how this is done. Ultimatley i have 2 questions.

    1. What is the difference between "Site" and "Application" projects that makes this a problem for one and not the other?

    2. How do i get my new application project to build Smile

    Thanks.

    Steve.

     

    (1)

    Web-Site Project is a project type that is built-in to VS.NET 2005. It provides a structure for building an ASP.NET web-based application. For compilation, as Web-Site Project uses the "new" compilation model for web-sites promoted by VS.NET 2005. This compilation model rests on the Precompilation of the site and it is quite different from the "old" compilation model in VS.NET 2003. There are many ways to configure Precompilation, but, in general the site compiles to >1 DLL files and 0..N content files/placeholders. It is complicated, but not too much so once you find the Precompilation configuration that you like. It can be more secure that the old VS.NET 2003 compilation model. See below for more details.

    A Web-Application Project is a project type that is provided as an add-on project type. The Web-Application Projects compile to (generally) a single-DLL and 1...N content files. It is, pretty much, the same compilation model that VS.NET 2003 used.

    (2)

    You have a good question regarding signing a single DLL file.

    Here is some information, but I got stuck trying to find the "module name", as mentioned in the MSDN help.

    Here are some of the steps.

    1. First, you need to create a Public/Private Key Pair.
    2. Choose >Start, >Programs, >Microsoft Visual Studio 2005, >Visual Studio Tools, >Visual Studio 2005 Command Prompt.
    3. Enter the following at the command prompt and then press Enter...
      sn -k C:\Temp\sgKey.snk
    4. Now the key pair is created.
    5. Next, sign the assembly, (for example  "MyAssembly.dll"), with a strong name using the key file, (for example "sgKey.snk").
    6. At that point, MSDN, says... "At the command prompt, type the following command:
      al /out:<assembly name> <module name> /keyfile:<file name>
      In this command, assembly name is the name of the assembly to sign with a strong name, module name is the name of the code module used to create the assembly, and file name is the name of the container or file that contains the key pair."
    7. What is NOT clear to me is where one gets the "module name". Where does that come from if one is only starting with a singe file, MyAssembly.dll??? I want to type something like this...
      al /out:"c:\Temp\MyAssembly.dll" MyModule.netmodule /keyfile:"c:\Temp\sgKey.snk"
      ...but the file MyModule.netmodule does not exist. What gets used for "module name" when one starts with a single file???

    So, for question (2) I am just adding to the question and (I hope) framing it a bit --

    So that one can sign a single DLL file Assembly with the Assembly Linker (al.exe), where does one get a "module file" for the command line syntax if one is starting with just a single DLL file?

    (Note that most of the signing information above is paraphrased from MSDN.)

    For more details, check here...

    ASP.NET Web Site Precompilation -- http://msdn2.microsoft.com/en-us/library/ms228015.aspx

    How to: Create a Public/Private Key Pair  -- http://msdn2.microsoft.com/en-us/library/6f05ezxy.aspx

    How to: Sign an Assembly with a Strong Name -- http://msdn2.microsoft.com/en-us/library/xc31ft41.aspx

     

    If you or anyone finds an answer to the "when does one get the module name" question, please post it.

    Thank you.

    -- Mark Kamoski

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    01-05-2007, 10:41 AM
    • Member
      point Member
    • steven.miles
    • Member since 01-05-2007, 12:03 PM
    • Posts 2

    Thanks Mark,

    I understand that the the 2 projects types are different and use different build models and that it's something to do with the new build model that is causing the "Web Application Project" to have problems with my unsigned 3rd party assembly. Maybe question 1 should have been

    1. What difference in the build models causes the assembly generation failure in "Web Application Projects" and not in "Web Site Projects" when the web project is signed and references an unsigned assembly?

    I use a key (.snk) that is already generated. This is about where i got to in my search. I know how to sign an assembly if i have the source Smile. The ideal solution would be one that does not need me to sign the 3rd party assembly or does behind the scenes basically making my web application project work the same way as my web site project in this context.

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    01-05-2007, 1:20 PM
    • Contributor
      4,773 point Contributor
    • mkamoski
    • Member since 07-04-2002, 8:05 PM
    • ZULU-0500
    • Posts 1,299
    steven.miles:

    ...I know how to sign an assembly if i have the source Smile. The ideal solution would be one that does not need me to sign the 3rd party assembly or does behind the scenes basically making my web application project work the same way as my web site project in this context.

    Yes, that's is where I am stuck too.

    I can sign an assembly when I have the source.

    But, I cannot sign an assembly when all I have is a single DLL.

    If you find an answer, then please post it.

    I am sorry that I cannot be of more help.

    Thank you.

    -- Mark Kamoski

     

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    02-15-2007, 9:06 PM
    • Member
      79 point Member
    • Johnson_wei
    • Member since 11-07-2006, 3:34 AM
    • Posts 32
    I find the answer:
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=397923&SiteID=1
  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    10-08-2008, 7:16 AM
    • Member
      2 point Member
    • Pagial
    • Member since 10-08-2008, 8:26 AM
    • Posts 1

    Hi, I'm not really that experienced but i had a similar error. I created an web part application, and i wanted to reference a windows applicetion exe file that i compiled on a different project. After reading this post I played around with the advise here and did a couple of things different and my project worked.

    Note that I was using VS 2005 

    step 1. I created a publiic/private key as provided above...

    step 2. Opened the project i wanted to reference, right-clicked on the class library of that project and clicked on properties.

    step 3. Clicked on the signing tab, check the "Sign the assembly" and on the "Choose a strong name key file:" browse to the path where you created the public/private key. e.g C:\Temp\sgKey.snk

    step 4. Compile your project and you might be ok... i know i wasBig Smile

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    03-23-2009, 11:11 AM
    • Member
      2 point Member
    • duke_saeed
    • Member since 03-23-2009, 3:08 PM
    • Posts 1

    this is greate man !!

    the best answer was the simplest

    thank u

     

    It worked for meBig Smile

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    04-24-2009, 3:38 AM
    • Member
      2 point Member
    • vejula
    • Member since 11-22-2007, 9:50 PM
    • Tartu, Estonia
    • Posts 1

     That worked for me.  Pagial, you simply the best! :)

  • Re: Assembly generation failed -- Referenced assembly does not have a strong name

    04-24-2009, 7:39 AM
    • Member
      2 point Member
    • purkar rahul
    • Member since 04-24-2009, 7:28 AM
    • Posts 1

    nice code

Page 1 of 1 (9 items)