Registration [Error] xlfRegister call failed for function or command
A client of mine is getting the following message
Registration [Error] xlfRegister call failed for function or command: 'my function'
I am rather clueless as what could be the problem, the error only seems to happen irregullary.
Does excelDna write more detailed information somewhere, to narrow down the problem?
You can enable a higher level of logging to see the exact call that is failing - in this case you need the 'Info' level of logging enabled.
.NET Framework 4.x Logging Configuration
If you are targeting .NET Framework 4.x, you can use a .config file to set up the logging, with these instructions: https://excel-dna.net/docs/archive/wiki/Diagnostic-Logging
Simplest is to add this .config file next to your .xll file (with name <MyAddIn>.xll.config), giving you a .log file after running.
<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>
.NET 6 Logging Configuration
If you are targeting .NET 6, you can't use the .config file, and have the following options to configure the logging:
Set environment variables to configure the logging, then restart Excel:
EXCELDNA_DIAGNOSTICS_DEBUGGER_LEVEL=Verbose EXCELDNA_DIAGNOSTICS_FILE_LEVEL=Verbose EXCELDNA_DIAGNOSTICS_FILE_NAME=ExcelDna.log EXCELDNA_DIAGNOSTICS_LOGDISPLAY_LEVEL=Verbose EXCELDNA_DIAGNOSTICS_SOURCE_LEVEL=All
Set Registry entries under either of the keys
HKEY_CURRENT_USER\Software\ExcelDna\Diagnostics
HKEY_CURRENT_USER\Software\ExcelDna\Diagnostics
Then use these values, similar to the environment variables
-
SourceLevel- One of theSystem.Diagnostics.SourceLevelenum values, applied as the TraceSource level. -
LogDisplayLevel- One of theSystem.Diagnostics.TraceEventTypeenum values, applied to the built-in Excel-DNA logging display. -
DebuggerLevel- One of theSystem.Diagnostics.TraceEventTypeenum values, applied to the debugger trace listener. -
FileLevel- One of theSystem.Diagnostics.TraceEventTypeenum values, applied to theTextWriterTraceListener. -
FileName- The file name for theTextWriterTraceListener.
Thanks for the fast response.
Will come back to you once I have further data, most likely will take some days until client creates *.config file and error reoccures and provides feedback.
Sadly, never got feedback with Logs activated. They nstalled a new version of my app, which has a newer excel dna library dependecy. This seems to have solved the issue at hand. So, I don't no what caused the problem to begin with.
Finally... I received logs for this error, but sadly those logs aren't helpful to me, maybe they are to you. The logs only state that there was an error, but not what the error was:
ExcelDna.Integration Verbose: 1 : In XlAddIn.XlAutoOpen
ExcelDna.Integration Verbose: 1 : Enter Integration.DnaLibraryAutoOpen
ExcelDna.Integration Verbose: 3 : Register RegistrationInfo - XllPath=[Path]-AddIn.xll, ProcName=RegistrationInfo, FunctionType=QQ, MethodName=RegistrationInfo_abe05ed94c825150b87d4caea2f22bed - Result=-768278527
ExcelDna.Integration Verbose: 3 : Register SyncMacro - XllPath=[Path]-AddIn.xll, ProcName=SyncMacro, FunctionType=>B, MethodName=SyncMacro_abe05ed94c825150b87d4caea2f22bed - Result=1756364802
ExcelDna.Integration Verbose: 3 : Registering 47 methods
ExcelDna.Integration Information: 3 : Register - XllPath=[Path]-AddIn.xll, ProcName=f0, FunctionType=QQQ#, Name=[Function Name] - Result=ExcelDna.Integration.ExcelEmpty
ExcelDna.Integration Error: 3 : xlfRegister call failed for function or command: '[Function Name]'
[last 2 lines repeat for the other 46 methods]
Note the previous claim:
This seems to have solved the issue at hand.
was a lie, the user simply didn't see the issue anymore because when the *.config file is present it doesn't produce the User Interface any more but instead it wrote the error into the log.
This user interface:
So, what the user believed to be a fix, was simply a silent ignore, because the error never disappeared, it was just written to the file instead of a pop up window, and user wasn't aware of the fact.
We notice this, when we published a new version and the *.config was overwriten an it didn't log to file anymore the user would again report the error.
So it seemed to work just fine with the *.config, but without it the error poped up.
Long story short, finally have logs of the still ongoing issue.
/ping @govert (maybe you missed the reopen of the issue and my comment)
Is this still true?
[...] the error only seems to happen irregularly.
You might try to see if it makes a difference to load the add-in via "File -> Open" vs. the "Alt+t, i" dialog box.
If it always fails on a particular machine, you can start by checking that VBA is installed correctly (at least check that Alt+F11 opens the VBA IDE).
Otherwise, we could test whether a simple C add-in works (this uses the same xlfRegister call to add a function, but involves no Excel-DNA code).
Is this still true?
Yes, even in the provided logs only a couple of lines later I see this:
ExcelDna.Integration Information: 1 : SynchronizationManager - Install
ExcelDna.Integration Verbose: 1 : [AddInName] - End Initialize
ExcelDna.Integration Verbose: 1 : Exit DnaLibrary.Initialize
ExcelDna.Integration Verbose: 1 : In XlAddIn.XlAutoOpen
ExcelDna.Integration Verbose: 1 : Enter Integration.DnaLibraryAutoOpen
ExcelDna.Integration Verbose: 3 : Register RegistrationInfo - XllPath=[Path]-AddIn.xll, ProcName=RegistrationInfo, FunctionType=QQ, MethodName=RegistrationInfo_abe05ed94c825150b87d4caea2f22bed - Result=-768278527
ExcelDna.Integration Verbose: 3 : Register SyncMacro - XllPath=[Path]-AddIn.xll, ProcName=SyncMacro, FunctionType=>B, MethodName=SyncMacro_abe05ed94c825150b87d4caea2f22bed - Result=1756364802
ExcelDna.Integration Verbose: 3 : Registering 47 methods
ExcelDna.Integration Information: 3 : Register - XllPath=[Path]-AddIn.xll, ProcName=f0, FunctionType=QQQ#, Name=[Function Name] - Result=-877133821
ExcelDna.Integration Information: 3 : Register - XllPath=[Path]-AddIn.xll, ProcName=f1, FunctionType=QQQQQQ#, Name=[Function Name] - Result=-878182396
Alt+t, i seems to be a localized shortcut, since on my german excel it results in nothing.
What is the name of the dialog box?
If it always fails on a particular machine, you can start by checking that VBA is installed correctly (at least check that Alt+F11 opens the VBA IDE).
It happens on a particular machine but not on for all users on this machine. The machine is a terminal server and multiple users connect per mstsc (remote session) to this machine and only 2 users report the issue.
Otherwise, we could test whether a simple C add-in works (this uses the same xlfRegister call to add a function, but involves no Excel-DNA code).
Is there a sample available to test this?
I got a 23 MB log file and it failed 98 times, and it succeded 731 times.
"Alt+t, i" is the "Add-ins" dialog that you can get through "File -> Options -> Add-ins, Manage: Excel Add-ins, Go...".
I'm wondering whether the add-in is somehow (initially?) loaded in a context where the registration fails, like from another add-in or from a COM call. Maybe something is timing dependent, or something else is running in the Excel at startup, like some VBA code, which might block the registration.
For testing with the native code samples from the Excel SDK, I have this from a previous support incident:
Here is a slightly tweaked version of the Excel SDK https://www.dropbox.com/s/ssvpe7quyxpdvje/Excel2013XLLSDK.zip?dl=0 There are also two pre-built add-ins in the samples. Excel2013XLLSDK\SAMPLES\EXAMPLE\x64\RELEASE\EXAMPLE.xll – function like =CalcCircum(…) Excel2013XLLSDK\SAMPLES\GENERIC\x64\RELEASE\GENERIC.xll – function like =FuncSum(…)
The only tweaks are to make it compile without warnings (which are errors by default in my VS 2022 installation). I just compile from an “x64 Native Tools Command Prompt for VS 2022” and run from the SAMPLES directory
make build release x64
and FYI addin gets loaded by having a link in xllstart folder.
and FYI addin gets loaded by having a link in xllstart folder.
What else gets loaded at startup?
What else gets loaded at startup?
Would need to check with the customer, which will take some time again, response time is very slow.
generic.xll gives this error, when I hit CTRL + N to create a new workbook (on my personal machine)
translation would be something like this: "The macro !fshowdialog cannot be executed. The macro might not be available in this workbook, or all macros have been disabled."
this is just a FYI, don't need a fix, example.xll should be enough, or don't you think?
I also get the fShowDialog error upon Ctrl+N (similar error with Ctrl+M) - I don't think the way they register the shortcuts in that example works anymore.
Yes, you are just trying to see if function registration works, so either add-in will work. Not sure what the procedure would be to get it to load in the same way as when you're seeing problems with the Excel-DNA add-in...