Hi Michele,
You’re right that the file ExcelDna.Integration.dll does not have to be in the output directory.
A version of this is already packed inside the .xll file.
I suggest you uninstall any ExcelDna packages from your project, make sure there are no ExcelDna.* files left under the project folder or its packages folder.
Also check that you then have no reference in your project to some ExcelDna.Integration assembly somewhere else.
Then reinstall the ExcelDna.AddIn package, and everything should be set up correctly.
If that doesn’t work, write back and I can try to think of some more steps to debug the situation.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/0d97fcf4-c4e8-473c-8baa-bf8b32ee38e0n%40googlegroups.com.
On Jan 8, 2022, at 1:15 AM, Govert van Drimmelen <govert.va...@gmail.com> wrote:
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/ZNAZrSPJru0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/023701d80457%240f065a10%242d130e30%24%40gmail.com.
Hi Govert –
Thanks for your amazingly quick reply.
In answer to your first question, I am working solely within an "Excel VSTO add-in" setting. I created an "Excel VSTO solution" and used the “NuGet Package Manager” to install the following:
In answer to your second question, following is my “ThisAddIn” coding. When “gxlApplication = ExcelDnaUtil.Application” executes, I get the “Could not load file or assembly ExcelDna.Integration” error, and the ribbon tab isn’t created.
Imports ExcelDna.Integration
Public Class ThisAddIn
Public Shared gxlApplication As Excel.Application
Private Sub ThisAddIn_Startup() Handles Me.Startup
' ========= The following statement generates the error. =========
gxlApplication = ExcelDnaUtil.Application
MsgBox(Prompt:="gxlApplication.Application.Name=" & gxlApplication.Application.Name, Title:="ThisAddIn_Startup")
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
MsgBox(Prompt:="gxlApplication.Application.Name=" & gxlApplication.Application.Name, Title:="ThisAddIn_Shutdown")
End Sub
Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
Return New RibbonKalends()
End Function
End Class
I have explored an alternative:
gxlApplication = Globals.ThisAddIn.Application
' see https://stackoverflow.com/questions/10347495/excel-program-using-c-sharp-vsto#answer-10361091
The alternative appears to execute properly, up to a point:
Thus, the gxlApplication object works fine on Startup and Shutdown, but is Nothing at chronologically intermediate locations. Very strange.
Thanks for taking the time to look at this.
-- Paul
Hi Paul,
Excel-DNA is not designed to work as part of a VSTO add-in, though I don’t really know what the implications or blocks would be in this setting. Where possible, Excel-DNA attempts to be an alternative to VSTO (for Excel)
The context where VSTO loads the add-in for the first time, and runs the Startup routine might be one where Excel-DNA cannot find the COM Application object. For VSTO I think there is a an “Application” object available everywhere (I guess that’s the ThisAddIn.Application), so I’m not sure why you need to get it through the Excel-DNA mechanism. But you report having a problem with this approach too – I’m not sure why.
What I would suggest is to not make the add-in a VSTO add-in. So you just make a “Library (.NET Framework)” project and install the Excel-DNA packages.
Then you handle the startup like this:
Imports ExcelDna.Integration
Public Class MyAddIn
Implements IExcelAddIn
Public Sub AutoOpen() Implements IExcelAddIn.AutoOpen
MsgBox("Add-In Loaded")
End Sub
Public Sub AutoClose() Implements IExcelAddIn.AutoClose
End Sub
End Class
There are some aspects you lose when taking out the VSTO part:
If you really need these VSTO abilities, you might need to make two add-ins, one as a normal VSTO add-in that does not reference Excel-DNA at all, and the other an Excel-DNA add-in that does not reference VSTO at all, and exposes the worksheet UDFs that VSTO can’t provide. The Excel-DNA add-in would be completely separate, though it can be loaded automatically by the VSTO add-in using a call to Application.RgisterXLL(…).
Over the long term, I think you’re better off without VSTO if possible and a simpler add-in using just Excel-DNA.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/7bae847c-1d42-4fad-b427-82bbcc9318e4n%40googlegroups.com.