DnaLibrary AutoOpen Error

2,384 views
Skip to first unread message

Gareth Hayter

unread,
Sep 10, 2015, 1:32:11 PM9/10/15
to Excel-DNA
Hi Govert

Any suggestions about where to start debugging these errors (reported by my users, but I'm not experiencing them myself):

Initialization [Warning] Assembly EXCELAPI could not be loaded from resources. 
Initialization [Error] DnaLibrary AutoOpen Error : TargetInvocationException - Exception has been thrown by the target of an invocation.

Kind regards,
Gareth.

Caio Proiete

unread,
Sep 10, 2015, 2:56:52 PM9/10/15
to exce...@googlegroups.com
I usually get this exception (TargetInvocationException) when the add-in is disabled in Excel.

Inline image 1

--
Caio Proiete



--
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 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/d/optout.

Govert van Drimmelen

unread,
Sep 10, 2015, 4:43:45 PM9/10/15
to Excel-DNA
Hi Gareth,

The [Warning] is only displayed because the [Error] causes the LogDisplay to pop up.
The [Warning] is probably is bad configuration entry in the .dna file, related to an ExcelApi.dll assembly that is not needed or fails to load for some reason (maybe another dependency that fails).
Most likely the [Warning] happens on your machine too, but is not displayed. You can change the logging configuration to display warning too, or log it in some other way. 
Details of how to do the diagnostic logging configuration can be found on GitHub: https://github.com/Excel-DNA/ExcelDna/wiki/Diagnostic-Logging

The [Error] is an unhandled exception being thrown by your AutoOpen(), and might be harder to track down if it is not happening on your machine.
If you wrap the AutoOpen() code in an exception handler, you can isolate the exception and decide how to handle it yourself.
It's likely to be an error from some COM call - you might have to structure your AutoOpen so that you can find out which line is throwing, and then try to deduce what is different in the user's environment to cause the error.

-Govert

Gareth Hayter

unread,
Sep 10, 2015, 4:57:06 PM9/10/15
to Excel-DNA
Thanks Caio and Govert

I'll follow these leads and report back my discoveries.

An idea: it would be nice for these error messages, especially the TargetInvocationException  in AutoOpen to display more user-focused text, such as: 'This error is often caused by the add-in being disabled in Excel. Click here <URL> to learn how to fix this.'

Then, the <URL> is a webpage explaining is simple terms (and screenshots) the steps that an end-user needs to perform to check and fix. It would be nice ff this message could somehow be defined in the .dna file together with a sensible default that points to a page on the Excel DNA GitHub site.

Cheers,
Gareth

Govert van Drimmelen

unread,
Sep 10, 2015, 5:04:46 PM9/10/15
to exce...@googlegroups.com
Hi Gareth,

I agree that more detailed and helpful error messages would be a step forward.

Standardizing the logging mechanism (and allowing you to configure it for your add-in) is a big step in that direction.
You can now completely configure the error handling yourself to swap out the standard dialog, and display any message or dialog you want, or none, if you prefer.

In this case, I'm not sure there's much we can say that is useful.
The TargetInvocationException just means a COM call failed. I'm not so sure the context where you are reporting the error matches the suggestion from Caio, though it's certainly worth checking.

-Govert



From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Gareth Hayter [gareth...@gmail.com]
Sent: 10 September 2015 10:57 PM
To: Excel-DNA
Subject: [ExcelDna] Re: DnaLibrary AutoOpen Error

--
Reply all
Reply to author
Forward
0 new messages