--------------------------------------------------
Easily add Excel-DNA support to your private or corporate GitHub account.
--------------------------------------------------
Hi Brian,
This sounds like quite a serious bug in the add-in, Excel-DNA or Excel itself
I have not heard of anything like this before.
My first suggestion would be to confirm the registration strings that your functions are registered with, to make sure they are not being registered as ThreadSafe for some reason.
(Or does your add-in have some other IsThreadSafe=true functions?)
For this you can add an app.config file to the project and enable verbose logging to a file.
The config file might contain this:
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4"/>
<sources>
<source name="ExcelDna.Integration" switchValue="All">
<listeners>
<remove name="Default"/>
<add name="LogDisplay" type="ExcelDna.Logging.LogDisplayTraceListener,ExcelDna.Integration">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Off"/>
</add>
<add name="File"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="ExcelDnaAddIn.log" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
Then run your add-in and check for a new ExcelDnaAddIn.log file.
The log file will have some entries like this, with the FunctionType the part we're interested in:
ExcelDna.Integration Information: 3 : Register - XllPath=C:\Temp\CsDnaLogging\bin\Debug\CsDnaLogging-AddIn64.xll, ProcName=f0, FunctionType=QC%, Name=Test - Result=568131587
For ThreadSafe functions, the FunctionType will have a suffix $ like this
ExcelDna.Integration Information: 3 : Register - XllPath=C:\Temp\CsDnaLogging\bin\Debug\CsDnaLogging-AddIn64.xll, ProcName=f0, FunctionType=QC%$, Name=Test - Result=568131587
So you can check for anything suspicious around the registration from the log.
Another consideration is how your function is being called. If the function is considered async and being transformed by the ExcelDna Registration extension, then your the function would be called from another thread, even though the wrapper function with the Registration extension creates will be called on the main thread. It doesn't sound like you're in this situation , but it's worth confirming.
The Excel-DNA registration always runs on the main thread, so it's not clear that a race condition at the actual registration time.
However, depending on how your functions are processed before the Registration call, one might image an ExcelFunctionAttribute object might end up in the wrong place.
Beyond this, it might be a bug in Excel. Then might be quite hard to report without something to reproduce, but you might at least press the "Send a frown" button. If they changed anything related recently, maybe that rings an alarm bell.
In any event, please report back if you find out anything more.
-Govert