Hello Excel-DNA team!
Let me quickly describe my setup so my question will hopefully be more precise.
I am developing an Excel add-in through ExcelDNA with auto-updates.
As advised by your other threads I chose the unpacked approach, so I can update the *.dll libraries while Excel with the add-in is still running.
But also, as you wrote
here I thought I will give it a try to auto-registering.
Since this is quite an old answer, I am using ExcelIntegration instead of Application to do so, so it's like:
ExcelIntegration.RegisterXLL(ExcelDnaUtil.XllPath);
But unfortunately, it doesn't work. I am having my Excel opened, with add-in in version 0.2. Then I am overwriting dll files so they become 0.3 in addin lib directory and run RegisterXll - my Excel closes without any message (even when there are unsaved changes in the sheet).
I also found your thread where you're pointing out I should queue it up, so I tried:
ExcelAsyncUtil.QueueAsMacro(() =>
{
ExcelIntegration.UnregisterXLL(ExcelDnaUtil.XllPath); // Should not need this if you are re-registering...
ExcelIntegration.RegisterXLL(ExcelDnaUtil.XllPath);
});
Both with and without Unregistering. An approach without unregistering just closes the Excel as in the no-macro variant. When I did debug it, the exception just before says:
Exception of type 'ExcelDna.Integration.XlCallException' was thrown.
Putting Unregister in just before the call finally gives me some error in Excel which looks like in the screenshot attached.
The addin logger says:
ExcelDna.Integration Error: 6 : Unexpected error trying to run SyncMacro for queued macro execution. : TargetInvocationException - Exception has been thrown by the target of an invocation.
As you wrote on this StackOverflow thread, I am NOT copying ExcelIntegration into the lib folder (however, I also tried what happens when it is actually there - with no success though).
The add-in is re-loading correctly if I am doing File->Open.. -> xll
So, my question is: am I able to register this addin automatically from the code? Do I perform any mistake in the process or that's how it is in my case?
Appreciate your thoughts on that.
Cheers,
Wojciech