xlfRegister Failed Error for COM & XLL combined Addin

Add-in Express™ Support Service
That's what is more important than anything else

xlfRegister Failed Error for COM & XLL combined Addin
XLL Registration succeeds for Excel 2007 and above but fails for Excel XP (2002) 
Subscribe
Jim J




Posts: 9
Joined: 2019-03-26
Hi,

I am trying to build an Excel COM & XLL Addin that is compatible with Excel 2002-2019 & Excel 365. I have finished testing the addin for 2007 and above and am now trying to get Excel 2002 working. The COM addin part works fine but I get the following error when Excel starts.

Also please note that only some XLL functions fail to register while others succeed.

FYI my test VM is Windows XP SP3 and my Excel 2002 version is 10.6871.6870 SP3

Detailed technical information follows:
---
Date and Time: 4/9/2019 6:44:32 PM
Machine Name: VMWINXPX86OFCXP
IP Address: 192.168.201.130
Current User: VMWINXPX86OFCXP\Jim

Application Domain: C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\
Assembly Codebase: file:///C:/WINDOWS/assembly/GAC_MSIL/AddinExpress.MSO.2005/9.2.4635.0__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name: AddinExpress.MSO.2005, Version=9.2.4635.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 9.2.4635.0

Exception Source: AddinExpress.MSO.2005
Exception Type: System.ApplicationException
Exception Message: 'xlfRegister' failed. Function name: udfTest
Exception Target Site: RegisterXlMethod

---- Stack Trace ----
AddinExpress.MSO.ADXXLLModule.RegisterXlMethod(mi As ADXExcelMethodInfo)
AddinExpress.MSO.2005.dll: N 0815 (0x32F) IL

I created a very simple addin to demonstrate the error that I will email support. It has an empty AddinModule COM component and an XLL component with only one function that just returns 'OK'.

There are 2 ways to get the addin to successfully register the XLL function when Excel starts.
1.) Change the 'udfTest' function description from "Test" to "". (Code Line #75 in the XLLTestUDFs.Designer.vb module)
2.) Remove arguments 21-30 in the declaration of the 'udfTest' Public Shared Function. (Code Line #91-93 in the XLLTestUDFs.vb module)

It appears for Excel 2002 if I have a function description then I can only have 20 function arguments while if I remove the function description I can have the Excel 2002 limit of all 30 arguments.

I believe the issue is the length of some string argument used to register the XLL function but I am confused by the fact that if I remove the 4-letter function description of 'Test' I can successfully register a function with an additional 10 more arguments.

With Excel 2007 and greater I have no issues registering this function.

Below is my adxloader.log and you'll noticed there are no issues.

Add-in Express Loader Log File: 04/09/2019 19:09:23:125

Startup directory: C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\
Loader version: 9.2.4635.0
Operating System: Microsoft Windows XP Professional Service Pack 3 (build 2600)
Process Owner: Administrator
Command Line: "C:\Progs\Microsoft Office\Office10\EXCEL.EXE"
Run 'As Administrator': Yes
Process Elevated: No
Integrity Level: Untrusted
UAC (User Account Control): Off
------------------------------------------------------------------------
19:09:23:125 0628 3112 The minimum supported Office version is 10
19:09:23:125 0628 3112 The host's version is 10.0.6871.0
19:09:23:125 0628 3112 Creating a new instance of the XLL loader.
19:09:23:125 0628 3112 Loading mscoree.dll
19:09:23:125 0628 3112 INFO: Assembly codebase - C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\TestAddinCOMXLL.dll.
19:09:23:125 0628 3112 INFO: Assembly version - 1.0.0.0.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Getting the CLSID of the managed XLL class.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Loading the configuration from the system registry.
19:09:23:125 0628 3112 Getting the latest CLR version.
19:09:23:125 0628 3112 The latest CLR version is 'v4.0.30319'.
19:09:23:125 0628 3112 The configuration has been loaded successfully.
19:09:23:125 0628 3112 Runtime version: v4.0.30319.
19:09:23:125 0628 3112 Assembly name: TestAddinCOMXLL, PublicKeyToken=01eff9b74af10789.
19:09:23:125 0628 3112 Class name: TestAddinCOMXLL.XLLTestUDFs.
19:09:23:125 0628 3112 Registry key: CLSID\{24B39A4A-CE21-3726-AFDB-E2C557784D77}.
19:09:23:125 0628 3112 Attempting to create a new instance of the managed XLL class: CLR - v4.0.30319
19:09:23:125 0628 3112 Loading CLR: v4.0.30319.
19:09:23:125 0628 3112 Calling CLRCreateInstance method.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Calling GetRuntime method.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Checking if the hosting API of .NET Framework v4.0 beta is installed.
19:09:23:125 0628 3112 The hosting API is up to date.
19:09:23:125 0628 3112 Calling SetDefaultStartupFlags method.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Calling GetInterface method for the CorRuntimeHost interface.
19:09:23:125 0628 3112 Success.
19:09:23:125 0628 3112 Starting CLR...
19:09:23:140 0628 3112 Success.
19:09:23:140 0628 3112 Getting the CLR version.
19:09:23:140 0628 3112 The CLR v4.0.30319 has been initialized successfully.
19:09:23:140 0628 3112 Creating a new domain setup.
19:09:23:140 0628 3112 Success.
19:09:23:140 0628 3112 Getting the add-in directory.
19:09:23:140 0628 3112 Success. The directory is 'C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\'
19:09:23:140 0628 3112 The 'shadow copy' is disabled.
19:09:23:140 0628 3112 Creating a new application domain.
19:09:23:171 0628 3112 Success.
19:09:23:171 0628 3112 Getting the base directory for the domain.
19:09:23:171 0628 3112 Success. The directory is 'C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\'.
19:09:23:171 0628 3112 Opening adxloader.dll.manifest.
19:09:23:171 0628 3112 Success. The manifest is 'C:\Documents and Settings\Jim\My Documents\Visual Studio 2010\Projects\TestAddinCOMXLL\TestAddinCOMXLL\bin\Debug\adxloader.dll.manifest'.
19:09:23:171 0628 3112 Getting the 'assemblyIdentity' element.
19:09:23:171 0628 3112 Success.
19:09:23:171 0628 3112 Getting the 'name' attribute.
19:09:23:171 0628 3112 Success. The name is 'TestAddinCOMXLL, PublicKeyToken=01eff9b74af10789'.
19:09:23:171 0628 3112 Getting the 'name' attribute.
19:09:23:171 0628 3112 Success. The class name is 'TestAddinCOMXLL.XLLTestUDFs'.
19:09:23:171 0628 3112 Attempting to create a new instance of the XLL class.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoOpen' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoClose' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoAdd' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoRemove' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoFree' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'autoFree12' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'addInManagerInfo' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'addInManagerInfo12' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'Dispose' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Getting the dispid of the 'initialize4' method.
19:09:23:203 0628 3112 Success.
19:09:23:203 0628 3112 Invoking the 'initialize4' method.
19:09:23:265 0628 3112 Success.
19:09:23:265 0628 3112 The instance of the managed XLL class has been created successfully.
19:09:23:265 0628 3112 Forwarding xlAutoOpen to the managed code.
19:09:24:703 0628 3112 Success.
19:09:24:718 0628 3112 Start.
19:09:24:718 0628 3112 The minimum supported Office version is 10
19:09:24:718 0628 3112 The host's version is 10.0.6871.0
19:09:24:718 0628 3112 Creating a new instance of the add-in loader.
19:09:24:718 0628 3112 Success.
19:09:24:718 0628 3112 Loading the configuration from the system registry.
19:09:24:718 0628 3112 Getting the latest CLR version.
19:09:24:718 0628 3112 The latest CLR version is 'v4.0.30319'.
19:09:24:718 0628 3112 The configuration has been loaded successfully.
19:09:24:718 0628 3112 Runtime version: v4.0.30319.
19:09:24:718 0628 3112 Assembly name: TestAddinCOMXLL, PublicKeyToken=01EFF9B74AF10789.
19:09:24:718 0628 3112 Class name: TestAddinCOMXLL.AddinModule.
19:09:24:718 0628 3112 Registry key: CLSID\{33C001CB-84DB-4D4D-8935-23C769641DC3}.
19:09:24:718 0628 3112 Attempting to create a new instance of the managed add-in class: CLR - v4.0.30319
19:09:24:718 0628 3112 Creating an instance of the managed class. Assembly identity: 'TestAddinCOMXLL, PublicKeyToken=01EFF9B74AF10789'
19:09:24:718 0628 3112 Success.
19:09:24:718 0628 3112 Unwrapping the managed class.
19:09:24:781 0628 3112 Success.
19:09:24:781 0628 3112 Querying the add-in extensibility.
19:09:24:781 0628 3112 Success.
19:09:24:781 0628 3112 Querying the custom task panes.
19:09:24:781 0628 3112 Success.
19:09:24:781 0628 3112 Querying the ribbon extensibility.
19:09:24:781 0628 3112 Success.
19:09:24:781 0628 3112 Querying the form regions.
19:09:24:781 0628 3112 Success.
19:09:24:781 0628 3112 Querying the encryption provider.
19:09:24:781 0628 3112 The 'EncryptionProvider' interface is not supported.
19:09:24:781 0628 3112 Getting the dispid of the 'Dispose' method.
19:09:24:796 0628 3112 Success.
19:09:24:796 0628 3112 Getting the dispid of the 'InitializeLoaderService' method.
19:09:24:796 0628 3112 Success.
19:09:24:796 0628 3112 Invoking the 'InitializeLoaderService' method.
19:09:24:796 0628 3112 Success.
19:09:24:796 0628 3112 The instance of the managed add-in class has been created successfully.
19:09:26:218 0628 3112 Forwarding xlAutoClose to the managed code.
19:09:26:218 0628 3112 Success.

Thanks,
Jim
Posted 09 Apr, 2019 18:12:56 Top
Andrei Smolin


Add-in Express team


Posts: 16334
Joined: 2006-05-11
Hello Jim,

Pre-2007 Excel versions are more restrictive. In particular, as far as I remember, they allow up to 28 parameters. Also, check the restriction we describe in section "My XLL Add-in doesn't show descriptions" at https://www.add-in-express.com/docs/net-excel-udf-tips.php#xll-no-descriptions. I suppose they allow longer descriptions in 2007+.

Note that you can use the OnBeforeFunctionAdd event to register your function with this or that number of parameters.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Apr, 2019 09:21:56 Top
Jim J




Posts: 9
Joined: 2019-03-26
Hi Andrei,

Did you get a chance to look at the sample addin I sent to the support email?

It shows behavior more buggy than what you describe. The function in my test addin will register correctly with all 30 arguments if I just remove the 4-letter function description of "Test". If I keep the function description then as soon as I add argument 21 it fails to register but if I have only 20 arguments it registers successfully.

What I don't understand is each function argument is named vArg01, vArg02 vArg03 etc which when you sum of the length of all arguments for 21 arguments and the comma separator the length of the string is only 146 ((6*21)+20) characters, well below the 255 character limit but yet it still fails to register with 21 arguments (below the 28 or 30 limit) and a 4-letter function description.

Also, please note the addin doesn't use any argument descriptions.

Any ideas why?

Thanks,
Jim
Posted 10 Apr, 2019 09:39:49 Top
Andrei Smolin


Add-in Express team


Posts: 16334
Joined: 2006-05-11
Jim,

Jim J writes:
register correctly with all 30 arguments if I just remove the 4-letter function description of "Test"


I may be wrong about 28 arguments. Deleting the description lets me suppose the issue may relate to the other restriction mentioned.

Tomorrow, I'll gather more information about the issue.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Apr, 2019 09:56:16 Top
Jim J




Posts: 9
Joined: 2019-03-26
Thanks Andrei for taking a closer look tomorrow.

Jim
Posted 10 Apr, 2019 10:12:56 Top
Andrei Smolin


Add-in Express team


Posts: 16334
Joined: 2006-05-11
Hello Jim,

I've tested your project in Excel 2003. I confirm that removing the function description allows registering 30 arguments. I've created a 1-symbol description for the first argument and got the same issue.

Looking in the code I see that we create an array of arguments for xlfRegister as described at https://docs.microsoft.com/en-us/office/client-developer/excel/xlfregister-form-1.

I've found a mistake however: according to that page, we should provide up to 20 parameter descriptions (pre-2007 Excel). In your case, we provide 30 (when you specify the function description or a parameter description). I assume this breaks xlfRegister. The issue is now filed under #14998 in our issue-tracking DB. You'll see this number in whatsnew.txt once the issue is fixed; supposedly, a new build will be available in 2-3 weeks.

Another way out of this would be to use an Excel Automation add-in.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Apr, 2019 06:11:24 Top
Jim J




Posts: 9
Joined: 2019-03-26
Andrei, thanks for looking deeper into this issue and confirming the registration bug.

Unfortunately, Excel automation functions will not work for my purpose but I look forward to testing the fix once it's available in the new build in a couple of weeks.

Regards,
Jim
Posted 11 Apr, 2019 09:29:32 Top
Andrei Smolin


Add-in Express team


Posts: 16334
Joined: 2006-05-11
I'll send you a note once the new build is published.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Apr, 2019 09:32:30 Top
Jim J




Posts: 9
Joined: 2019-03-26
Thanks.
Posted 11 Apr, 2019 09:36:36 Top
Andrei Smolin


Add-in Express team


Posts: 16334
Joined: 2006-05-11
Hello Jim,

Please find Add-in Express 9.3 published at https://www.add-in-express.com/downloads/adxnet.php.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 May, 2019 05:54:40 Top