UDF causing Excel to Crash

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

UDF causing Excel to Crash
 
ideaFocus




Posts: 63
Joined: 2013-07-19
Hi,

Here are the steps:

1. Added the new XLLModule
2. Uncommented the Sample UDF
3. Register the Project
4. Open Excel, function "AllSupportedExcelTypes" is there
5. Enter =AllSupportedExcelTypes(121) in any cell, you can give any value to UDF
6. Press Enter and crashes with following message: "Microsoft Excel has stopped working."

Code:


private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
            //
			// XLLModule
			//
			this.AddinName = "XLLModule";
        }



Note:
1. Unable to reproduce this with any other project.
2. Control doesn't go back to the UDF function for debugging.
3. I have also tried it with Unloading COM addin but it also doesn't work.

Thanks,
Attiqe
Posted 15 Jul, 2014 10:11:23 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Attiqe,

I cannot reproduce this. Is there any problem indicated in adxloader.log? Can you reproduce the crash if you turn all other Excel add-ins and COM add-ins off? Do you have several Excel versions on the machine?


Andrei Smolin
Add-in Express Team Leader
Posted 16 Jul, 2014 02:57:32 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

I have tested it on two machines one have only Excel 2013 and other one have both Excel 2010 and 2013 result is the same. I have disabled all other COM and Excel add-ins but nothing. Here's the log file:


Add-in Express Loader Log File: 07/16/2014 00:43:24:885

Startup directory: C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\
Loader version: 7.5.4072.0
Operating System: Microsoft Professional (build 9200), 64-bit
Process Owner: Administrator
Command Line: "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE"
Run 'As Administrator': No
Process Elevated: No
Integrity Level: Medium
UAC (User Account Control): On
------------------------------------------------------------------------
00:43:24:885 3032 8316 Start.
00:43:24:885 3032 8316 Reading the registry key 'HKEY_CLASSES_ROOT\CLSID\{D94DD481-5761-4CA3-B43A-47572F0D3FC8}'
00:43:24:885 3032 8316 Success. The registry key 'HKEY_CLASSES_ROOT\CLSID\{D94DD481-5761-4CA3-B43A-47572F0D3FC8}' is closed.
00:43:24:885 3032 8316 Converting the '{4BA250A6-8BCA-46A6-982A-F340081187C3}' CLSID from string.
00:43:24:885 3032 8316 Success.
00:43:24:885 3032 8316 Attempting to get the class object by the '{4BA250A6-8BCA-46A6-982A-F340081187C3}' CLSID.
00:43:24:885 3032 8316 Success.
00:43:24:885 3032 8316 Creating a new instance of the add-in loader.
00:43:24:886 3032 8316 Loading mscoree.dll
00:43:24:886 3032 8316 Success.
00:43:24:886 3032 8316 Loading the configuration from the system registry.
00:43:24:886 3032 8316 Getting the latest CLR version.
00:43:24:886 3032 8316 The latest CLR version is 'v4.0.30319'.
00:43:24:886 3032 8316 The configuration has been loaded successfully.
00:43:24:886 3032 8316 Runtime version: v4.0.30319.
00:43:24:886 3032 8316 Assembly name: PowerOutline, PublicKeyToken=521E0A50813E7CA0.
00:43:24:886 3032 8316 Class name: PowerOutline.AddinModule.
00:43:24:886 3032 8316 Registry key: CLSID\{D94DD481-5761-4CA3-B43A-47572F0D3FC8}.
00:43:24:886 3032 8316 Attempting to create a new instance of the managed add-in class: CLR - v4.0.30319
00:43:24:886 3032 8316 Loading CLR: v4.0.30319.
00:43:24:886 3032 8316 Calling CLRCreateInstance method.
00:43:24:886 3032 8316 Success.
00:43:24:886 3032 8316 Calling GetRuntime method.
00:43:24:886 3032 8316 Success.
00:43:24:886 3032 8316 Checking if the hosting API of .NET Framework v4.0 beta is installed.
00:43:24:886 3032 8316 The hosting API is up to date.
00:43:24:886 3032 8316 Calling GetInterface method for the CorRuntimeHost interface.
00:43:24:886 3032 8316 Success.
00:43:24:886 3032 8316 Starting CLR...
00:43:24:886 3032 8316 Success.
00:43:24:886 3032 8316 Getting the CLR version.
00:43:24:886 3032 8316 The CLR v4.0.30319 has been initialized successfully.
00:43:24:886 3032 8316 Creating a new domain setup.
00:43:24:886 3032 8316 Success.
00:43:24:887 3032 8316 Getting the add-in directory.
00:43:24:887 3032 8316 Success. The directory is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\'
00:43:24:887 3032 8316 The 'shadow copy' is enabled.
00:43:24:887 3032 8316 Creating a new application domain.
00:43:24:887 3032 8316 Success.
00:43:24:887 3032 8316 Creating an instance of the managed class. Assembly identity: 'PowerOutline, PublicKeyToken=521E0A50813E7CA0'
00:43:25:063 3032 8316 Success.
00:43:25:063 3032 8316 Unwrapping the managed class.
00:43:25:073 3032 8316 Success.
00:43:25:073 3032 8316 Querying the add-in extensibility.
00:43:25:073 3032 8316 Success.
00:43:25:073 3032 8316 Querying the custom task panes.
00:43:25:073 3032 8316 Success.
00:43:25:073 3032 8316 Querying the ribbon extensibility.
00:43:25:073 3032 8316 Success.
00:43:25:073 3032 8316 Querying the form regions.
00:43:25:073 3032 8316 Success.
00:43:25:073 3032 8316 Getting the dispid of the 'Dispose' method.
00:43:25:075 3032 8316 Success.
00:43:25:075 3032 8316 The managed add-in class has been created successfully.
01:16:48:047 3032 8316 Start - xlAutoClose.
01:16:48:047 3032 8316 Creating a new instance of the XLL loader.
01:16:48:047 3032 8316 Success.
01:16:48:047 3032 8316 Getting the CLSID of the managed XLL class.
01:16:48:048 3032 8316 Success.
01:16:48:048 3032 8316 Loading the configuration from the system registry.
01:16:48:049 3032 8316 Getting the latest CLR version.
01:16:48:050 3032 8316 The latest CLR version is 'v4.0.30319'.
01:16:48:050 3032 8316 The configuration has been loaded successfully.
01:16:48:050 3032 8316 Runtime version: v4.0.30319.
01:16:48:050 3032 8316 Assembly name: PowerOutline, Version=1.0.0.3, Culture=neutral, PublicKeyToken=521e0a50813e7ca0.
01:16:48:050 3032 8316 Class name: PowerOutline.PoXllModule.
01:16:48:050 3032 8316 Registry key: CLSID\{38064809-9880-3BC2-926C-2D8215EA3ABD}.
01:16:48:050 3032 8316 Attempting to create a new instance of the managed XLL class: CLR - v4.0.30319
01:16:48:050 3032 8316 Getting the base directory for the domain.
01:16:48:050 3032 8316 Success. The directory is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\'.
01:16:48:050 3032 8316 Opening adxloader.dll.manifest.
01:16:48:051 3032 8316 Success. The manifest is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\adxloader.dll.manifest'.
01:16:48:051 3032 8316 Getting the 'assemblyIdentity' element.
01:16:48:051 3032 8316 Success.
01:16:48:051 3032 8316 Getting the 'name' attribute.
01:16:48:051 3032 8316 Success. The name is 'PowerOutline, PublicKeyToken=521e0a50813e7ca0'.
01:16:48:051 3032 8316 Getting the 'name' attribute.
01:16:48:051 3032 8316 Success. The class name is 'PowerOutline.PoXllModule'.
01:16:48:051 3032 8316 Attempting to create a new instance of the XLL class.
01:16:48:062 3032 8316 Success.
01:16:48:062 3032 8316 Getting the dispid of the 'autoOpen' method.
01:16:48:064 3032 8316 Success.
01:16:48:064 3032 8316 Getting the dispid of the 'autoClose' method.
01:16:48:064 3032 8316 Success.
01:16:48:064 3032 8316 Getting the dispid of the 'autoAdd' method.
01:16:48:064 3032 8316 Success.
01:16:48:065 3032 8316 Getting the dispid of the 'autoRemove' method.
01:16:48:065 3032 8316 Success.
01:16:48:065 3032 8316 Getting the dispid of the 'autoFree' method.
01:16:48:065 3032 8316 Success.
01:16:48:065 3032 8316 Getting the dispid of the 'autoFree12' method.
01:16:48:065 3032 8316 Success.
01:16:48:065 3032 8316 Getting the dispid of the 'addInManagerInfo' method.
01:16:48:065 3032 8316 Success.
01:16:48:065 3032 8316 Getting the dispid of the 'addInManagerInfo12' method.
01:16:48:066 3032 8316 Success.
01:16:48:066 3032 8316 Getting the dispid of the 'Dispose' method.
01:16:48:066 3032 8316 Success.
01:16:48:066 3032 8316 Getting the dispid of the 'initialize4' method.
01:16:48:066 3032 8316 Success.
01:16:48:066 3032 8316 Invoking the 'initialize4' method.
01:16:48:068 3032 8316 Success.
01:16:48:068 3032 8316 The managed XLL class has been created successfully.
01:16:48:068 3032 8316 Forwarding xlAutoClose to the managed code.
01:16:48:075 3032 8316 Success.


-A
Posted 16 Jul, 2014 04:23:35 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Attiqe,

Thank you. I assume you have a COM add-in + XLL add-in in the same assembly. Please turn off your COM add-in in the registry, start Excel and let me see adxloader.log. To turn a COM add-in off, you set LoadBehavior=0 in {HKLM and HKCU}\Software\Microsoft\Office\Excel\Addins\{your add-in}.


Andrei Smolin
Add-in Express Team Leader
Posted 16 Jul, 2014 07:41:55 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Here is as per your request:


Add-in Express Loader Log File: 07/16/2014 23:43:22:196

Startup directory: C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\
Loader version: 7.5.4072.0
Operating System: Microsoft Professional (build 9200), 64-bit
Process Owner: Administrator
Command Line: "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE" https://d.docs.live.net/cd4569b3f2739ac6/PowerOutline/PO%20Developers/Po.Risk.1.6.xlsx
Run 'As Administrator': No
Process Elevated: No
Integrity Level: Medium
UAC (User Account Control): On
------------------------------------------------------------------------
23:43:22:197 1632 6812 Start - xlAutoOpen.
23:43:22:197 1632 6812 Creating a new instance of the XLL loader.
23:43:22:197 1632 6812 Loading mscoree.dll
23:43:22:197 1632 6812 Success.
23:43:22:197 1632 6812 Getting the CLSID of the managed XLL class.
23:43:22:198 1632 6812 Success.
23:43:22:198 1632 6812 Loading the configuration from the system registry.
23:43:22:198 1632 6812 Getting the latest CLR version.
23:43:22:199 1632 6812 The latest CLR version is 'v4.0.30319'.
23:43:22:199 1632 6812 The configuration has been loaded successfully.
23:43:22:199 1632 6812 Runtime version: v4.0.30319.
23:43:22:199 1632 6812 Assembly name: PowerOutline, Version=1.0.0.3, Culture=neutral, PublicKeyToken=521e0a50813e7ca0.
23:43:22:199 1632 6812 Class name: PowerOutline.PoXllModule.
23:43:22:199 1632 6812 Registry key: CLSID\{38064809-9880-3BC2-926C-2D8215EA3ABD}.
23:43:22:199 1632 6812 Attempting to create a new instance of the managed XLL class: CLR - v4.0.30319
23:43:22:199 1632 6812 Loading CLR: v4.0.30319.
23:43:22:200 1632 6812 Calling CLRCreateInstance method.
23:43:22:200 1632 6812 Success.
23:43:22:200 1632 6812 Calling GetRuntime method.
23:43:22:200 1632 6812 Success.
23:43:22:200 1632 6812 Checking if the hosting API of .NET Framework v4.0 beta is installed.
23:43:22:213 1632 6812 The hosting API is up to date.
23:43:22:213 1632 6812 Calling GetInterface method for the CorRuntimeHost interface.
23:43:22:213 1632 6812 Success.
23:43:22:213 1632 6812 Starting CLR...
23:43:22:213 1632 6812 Success.
23:43:22:213 1632 6812 Getting the CLR version.
23:43:22:214 1632 6812 The CLR v4.0.30319 has been initialized successfully.
23:43:22:214 1632 6812 Creating a new domain setup.
23:43:22:217 1632 6812 Success.
23:43:22:217 1632 6812 Getting the add-in directory.
23:43:22:217 1632 6812 Success. The directory is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\'
23:43:22:218 1632 6812 The 'shadow copy' is enabled.
23:43:22:218 1632 6812 Creating a new application domain.
23:43:22:232 1632 6812 Success.
23:43:22:232 1632 6812 Getting the base directory for the domain.
23:43:22:232 1632 6812 Success. The directory is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\'.
23:43:22:232 1632 6812 Opening adxloader.dll.manifest.
23:43:22:232 1632 6812 Success. The manifest is 'C:\Users\Attiqe\Source\Workspaces\PowerOutline\PowerOutline\bin\Debug\adxloader.dll.manifest'.
23:43:22:232 1632 6812 Getting the 'assemblyIdentity' element.
23:43:22:232 1632 6812 Success.
23:43:22:232 1632 6812 Getting the 'name' attribute.
23:43:22:232 1632 6812 Success. The name is 'PowerOutline, PublicKeyToken=521e0a50813e7ca0'.
23:43:22:232 1632 6812 Getting the 'name' attribute.
23:43:22:232 1632 6812 Success. The class name is 'PowerOutline.PoXllModule'.
23:43:22:232 1632 6812 Attempting to create a new instance of the XLL class.
23:43:22:454 1632 6812 Success.
23:43:22:454 1632 6812 Getting the dispid of the 'autoOpen' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'autoClose' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'autoAdd' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'autoRemove' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'autoFree' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'autoFree12' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'addInManagerInfo' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'addInManagerInfo12' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'Dispose' method.
23:43:22:456 1632 6812 Success.
23:43:22:456 1632 6812 Getting the dispid of the 'initialize4' method.
23:43:22:456 1632 6812 Success.
23:43:22:457 1632 6812 Invoking the 'initialize4' method.
23:43:22:660 1632 6812 Success.
23:43:22:660 1632 6812 The managed XLL class has been created successfully.
23:43:22:660 1632 6812 Forwarding xlAutoOpen to the managed code.
23:43:22:794 1632 6812 Success.
Posted 16 Jul, 2014 13:49:31 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Attiqe,

Thank you.

That is, turning the COM add-in off lets your XLL add-in to start?

Note that the first log shows that the XLL add-in receives xlAutoClose at startup, while the last log shows it receives xlAutoOpen.

I have an impression your COM add-in closes Excel for some reason. This occurs when your XLL add-in should be loaded and this causes the issue.

What do you think?


Andrei Smolin
Add-in Express Team Leader
Posted 17 Jul, 2014 03:49:27 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

That is, turning the COM add-in off lets your XLL add-in to start?

Turning COM add-in off doesn't let XLL add-in start.

We did some further tests:

Test 1: SAMPLE UDF in VS and Excel in new Solution worked ok.
Test 2: When the Sample UDF is included in in PoXllModule and the Com Addin is enabled it fails in the same way.
Test 3: Removed POXLLModule > Added XLLModule1 > Com Enabled > Enabled Sample UDF > Registered/Build Project > Excel crashes same way

Test 4:
1. Create New Solution > Move PoXLLModule (Including Sample UDF and PO.ANCESTOR UDF) and Test
2. Move PowerOutline into new project and test
It resolved our issue but introduced many bugs.
Bug 1: adxloader64.PowerOutline.dll is not located and to resolve this I performed the same solution you have told earlier is to add new XllModule but it gives me this message: "The wrong project type."

Bug 2:

Detailed technical information follows:
---
Date and Time: 19-Jul-14 11:40:48 AM
Machine Name: C8288877100
IP Address: fe80::7d45:f951:223a:f1c8%10
Current User: C8288877100\Administrator

Application Domain: DefaultDomain
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version: 4.0.0.0

Exception Source:
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: Unable to create specified ActiveX control.
Exception Target Site: ForwardCallToInvokeMember

---- Stack Trace ----
System.RuntimeType.ForwardCallToInvokeMember(memberName As String, flags As BindingFlags, target As Object, aWrapperTypes As Int32[], msgData As MessageData&)
mscorlib.dll: N 0361 (0x169) IL
AddinExpress.MSO.ICTPFactory.CreateCTP(CTPAxID As String, CTPTitle As String, CTPParentWindow As Object)
mscorlib.dll: N 00000 (0x0) JIT
AddinExpress.MSO.ADXAddinModule.AddCustomTaskPanes(parent As Object, outlookFolderName As String)
mscorlib.dll: N 0682 (0x2AA) IL



Note that the first log shows that the XLL add-in receives xlAutoClose at startup, while the last log shows it receives xlAutoOpen.

I have an impression your COM add-in closes Excel for some reason. This occurs when your XLL add-in should be loaded and this causes the issue.

What do you think?

The SAMPLE UDF is appearing in the Formula bar and crashes Excel when the formula is completed after Enter but testing indicates that the SAMPLE UDF is not called ie the crash occurs before the UDF is actually executed.

It appears that when the Com addin is enabled then the Xll UDF receives an xlAutoClose and crashes on Execution but when the Com Addin is disabled no xlAutoClose is received but the Xll UDF still crashes on execution.

-A
Posted 18 Jul, 2014 20:46:53 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Attiqe,

ideaFocus writes:
but when the Com Addin is disabled no xlAutoClose is received but the Xll UDF still crashes on execution.


If you refer to bugs #1 and #2 above then they relate to configuring the add-in.

ideaFocus writes:
Bug 1: adxloader64.PowerOutline.dll is not located and to resolve this I performed the same solution you have told earlier is to add new XllModule but it gives me this message: "The wrong project type."


You need to create a COM Add-in project and add an XLL add-in project to it. Then copy the code.

ideaFocus writes:
Exception Message: Unable to create specified ActiveX control.


An incorrect class type name specified in the ADXTaskPane.ControlProgId property produces the same issue.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jul, 2014 10:18:22 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

The initial problem "UDF causing Excel to close." is resolved in the New Solution as requested and considering these points:

Andrei says:
'You need to create a COM Add-in project and add an XLL add-in project to it. Then copy the code.

Andrei says:
'An incorrect class type name specified in the ADXTaskPane.ControlProgId property produces the same issue.

However in the New Solution other errors arise:

1. Sorry we couldn't find adxloader64.projectname.dll (http://www.add-in-express.com/forum/read.php?FID=5&TID=12474 does not fix

2. Unable to Create ActiveX (see prior post above Posted 17 Jul, 2014 03:49:27)

Please advise next steps you can recommend.

Thanks.
Posted 21 Jul, 2014 11:54:11 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

Further comments and questions...

Current status:
1. the Current project works except the Sample and Our UDF crashes Excel on execution.

Questions:

a. What are possible things that could cause this? eg. Configuration, library versions, etc.
b. What approaches could we try to identify the problem?
c. Could we send you a minimal version of the project that demonstrates the problem?

Thanks
David
Posted 22 Jul, 2014 01:18:48 Top