none
Failure adding assembly to the cache: Attempt to install an assembly without a strong name RRS feed

  • Question

  • I am trying to add an interop dll to GAC using gacutil -i . but it is giving the following error.

    Failure adding assembly to the cache: Attempt to install an assembly without a strong name

    Please let me know how to resolve this.

     

    Thanks,
    Sudhakar

     

    Tuesday, March 30, 2010 4:49 AM

Answers

  • Hi Sudhakar,

    Thank you for your post.

    Failure adding assembly to the cache: Attempt to install an assembly without a strong name

    Based on the error message, it seems that this interop dll is not one strong-named assembly. Thus, when you applied gacutil -i command line to install it, you received this error message.

    For your concern, you might refer to the following document:

    How to: Install an Assembly into the Global Assembly Cache
    http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

    If we want to install assembly into GAC, we should add strong-named assemblies to the global assembly cache. Thus, please make sure that this interop dll is strong-named.

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by YiChun Chen Tuesday, April 6, 2010 3:38 AM
    Wednesday, March 31, 2010 8:40 AM

All replies

  • Hi Sudhakar,

    You cannot drop your DLL into GAC without strong-naming it using sn tool provided by .Net Framework.

    Follow these steps:

    1. Open .net command prompt.
    2. Go to the folder contanig DLL.
    3. Type sn -k test.snk, you can use any file name instead of test. This will create test .snk file in that folder.
    4. Open the assemblyinfo.cs file of project.
    5. Type file path in this tag [assembly:AssemblyKeyFile@"E:\hemant\practice\HP\bin\Debug\HP.snk")]
    6. Build application, finally your strong name created for your DLL.

    You can perform these steps from Visual Studio also http://msdn.microsoft.com/en-us/library/ms247123(VS.80).aspx

    Let me know if it was helpful to you.


    BR, PM
    • Proposed as answer by Rohit Gopidi Wednesday, April 4, 2012 6:35 PM
    Tuesday, March 30, 2010 5:29 AM
  • Hi Prasanjit,

    Thanks for the reply.

    I have tried , up to generating test.snk and able to generate  test.snk.  But after that  I could not understand how to proceed.

    I have tried by adding this test.snk in my project  VS2005 project properties ->signing->sign the assembly .

    but the build is failing saying it dll does not have strong name key.

    Please let me know in detail how to do the following steps. I did not find any assemblyinfo.cs file  in my C# project.

    1. Open the assemblyinfo.cs file of project.
    2. Type file path in this tag [assembly:AssemblyKeyFile@"E:\hemant\practice\HP\bin\Debug\HP.snk")]
    3. Build application, finally your strong name created for your DLL.

    ----------------------

    And one more thing I wonder is some time back it used to work without this strongname work around.

    The same interop dll we are used to use and it used to register in GAC. BUt i do not know why it suddenly not registred in the GAC.

    Please let me know if u have any idea on the above.

    Thanks for your help.

    Sudhakar

     

     

     

     

    Tuesday, March 30, 2010 8:49 AM
  • Ok,

    Have you added reference to this Interop assembly in your code?

    If you want to sign your Interop assembly manually, then run this command:

    tlbimp file.dll /out:SudhakarInterop.dll /keyfile:yourKey.snk

    TLBIMP is an Import tool available in .Net Framework.


    BR, PM
    Tuesday, March 30, 2010 9:13 AM
  • I already have an interop dll with me.

    I have added a reference to this interop dll in my project references in code.

     but if use gacutil -i xinterop.dll then it is giving  error saying

    Failure adding assembly to the cache: Attempt to install an assembly without a strong name.

    How to use tlbimp in my situation.

    tlbimp file.dll /out:SudhakarInterop.dll /keyfile:yourKey.snk

    here what is file.dll in my case.  Please explain me how to resolve this.

     

    Tuesday, March 30, 2010 12:28 PM
  • Hi Sudhakar,

    Thank you for your post.

    Failure adding assembly to the cache: Attempt to install an assembly without a strong name

    Based on the error message, it seems that this interop dll is not one strong-named assembly. Thus, when you applied gacutil -i command line to install it, you received this error message.

    For your concern, you might refer to the following document:

    How to: Install an Assembly into the Global Assembly Cache
    http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

    If we want to install assembly into GAC, we should add strong-named assemblies to the global assembly cache. Thus, please make sure that this interop dll is strong-named.

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by YiChun Chen Tuesday, April 6, 2010 3:38 AM
    Wednesday, March 31, 2010 8:40 AM
  • Excellent. This is really useful...Thank you very much...
    Wednesday, March 30, 2011 2:54 AM
  • Hi Sudhakar,

    Thank you for your post.

    Failure adding assembly to the cache: Attempt to install an assembly without a strong name

    Based on the error message, it seems that this interop dll is not one strong-named assembly. Thus, when you applied gacutil -i command line to install it, you received this error message.

    For your concern, you might refer to the following document:

    How to: Install an Assembly into the Global Assembly Cache
    http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

    If we want to install assembly into GAC, we should add strong-named assemblies to the global assembly cache. Thus, please make sure that this interop dll is strong-named.

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

    Why is this the selected answer the url provided simply addresses installing into the GAC, it does not mention how to strong name and the reader must continue to do a lot of digging for the information supplied in the other replies below.  If you are reading this just look at the other replies and save your time!!
    Tuesday, April 19, 2011 5:05 PM
  • Thanks Prasanjit, this worked like a charm !!
    Wednesday, April 4, 2012 6:36 PM