Referenced assembly does not have a strong name, error

1,138 views
Skip to first unread message

Zack Barresse

unread,
Jan 3, 2014, 5:11:26 AM1/3/14
to exce...@googlegroups.com
Hi all,

I'm making an VB.NET Excel add-in (Visual Studio 2012) and wanted to add some UDF's to it. Thought I'd try Excel DNA. I'm getting an error and I'm not sure how to correct it. I develop mostly in VBA, so I'm not extremely familiar with this environment. This is the error:

"Unable to emit assembly: Referenced assembly 'ExcelDna.Integration' does not have a strong name"

I used NuGet to add Excel DNA to the project (Project, Manage NuGet Packages). Added the .dna file to the project just fine. I thought maybe I had to reference the dll with this line...

<Reference Path="ExcelDna.Integration.dll" Pack="true" />

If I do not sign the assembly I get a slightly different error when I try to debug...

"Assembly 'C:\Users\...\packages\Excel-DNA.0.30.3\lib\ExcelDna.Integration.dll' must be strong signed in order to be marked as a prerequisite."

I'm not even sure if my functions are written appropriately. Anybody able to point me in the right direction here?

Zack

Govert van Drimmelen

unread,
Jan 3, 2014, 5:24:08 AM1/3/14
to exce...@googlegroups.com
Hi Zack,

1. You should not sign your .NET assembly. Because of the way Excel-DNA works, there is no extra security in doing the signing at this level. Once everything is working, you can sign the complete .xll file to enable security in Excel.

2. You should not add ExcelDna.Integration.dll as a <Reference ...> in the .dna file.

3. I suspect you started the VB.NET project by making an Office add-in. That might cause the strange messages you get. I'm not sure why that assembly would be considered a 'prerequisite' of anything.

The best way to get started is to make a VB.NET "Class Library" project, then add the NuGet package. Next, just copy the VB.NET code from displayed Readme.txt file in the source file, and press F5. It should work without any other changes.

Please write back if you need any more help.

Regards,
Govert

Zack Barresse

unread,
Jan 3, 2014, 4:22:36 PM1/3/14
to exce...@googlegroups.com
Hi Govert! Thanks for the response, I greatly appreciate it.

I did in fact start an Office add-in, apologies for not mentioning that. Is there a good way to add Excel DNA to the project this way? I ask because I'm not familiar with adding custom ribbons to plain class libraries, I've always used VSTO. #1 and 2 points taken. I'm not sure what is causing the error, but I'm assuming something in the VSTO solution requires strong names for all references. ? 

Zack

Govert van Drimmelen

unread,
Jan 3, 2014, 4:35:00 PM1/3/14
to exce...@googlegroups.com
Hi Zack,

Excel-DNA and VSTO won't go together in one solution (though separate add-ins can live happily together in Excel).
So you should not try to add an Excel-DNA project to a VSTO one, many things will go wrong.

You can add a ribbon to the Excel-DNA add-in, but you have to get hold of the ribbon customUI xml. If you have designed a ribbon using the VSTO tools, you can export the xml from the designer and use in the Excel-DNA add-in. The ribbon implementation works a bit different though - Excel-DNA does not have the high-level wrapper classes that you find in VSTO built in yet. The ribbon in Excel-DNA works more like the way it works with VBA - you make and save the customUI xml and have the callbacks in your code.

If you just want to get started, and need a way to run a macro, you can mark it the code like this:

Imports ExcelDna.Integration

Public Module MyAddIn
<ExcelCommand(MenuName:="My Menu", MenuText:="Run My Macro"> _
Public Sub MyMacro()
    Dim app = ExcelDnaUtil.Application
    app.Range("A1").Value = 42
End Sub
End Module


This will add a menu to the "Add-Ins" ribbon tab, allowing you to run the macro.

-Govert

Zack Barresse

unread,
Jan 3, 2014, 4:45:52 PM1/3/14
to exce...@googlegroups.com

Ok, I see. Thanks very much for the clarification Govert, that clears up a lot for me!

 

Zack

--
You received this message because you are subscribed to a topic in the Google Groups "Excel-DNA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/exceldna/X8qTUUTvUWY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages