Here's an odd one. I have Excel-DNA 0.33.9 under Excel 2013, and I'm trying to load an XLL add-in that uses the ribbon. I need to load it indirectly from an XLA, so sometime after the XLA add-in loads, I run this:
Application.RegisterXLL "c:\path\to\folder\CommandBars.xll"
Specifically, I have code in the Workbook_Open event that uses Application.OnTime to run it.
Under normal circumstances, this works fine. But when I open a file in protected view, the XLL fails to load, throwing an exception:
Initialization [Error] Integration.DnaLibraryAutoOpen Error : COMException - Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
The call stack looks like this:
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.GetApplicationFromWindow(System.IntPtr hWndMain)
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.GetApplicationFromWindows15.AnonymousMethod__0(System.IntPtr hWndEnum, System.IntPtr param)
[Native to Managed Transition]
[Managed to Native Transition]
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.GetApplicationFromWindows15()
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.GetApplicationFromWindows()
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.GetApplication()
ExcelDna.Integration!ExcelDna.Integration.ExcelDnaUtil.Application.get()
ExcelDna.Integration!ExcelDna.Integration.ExcelComAddInHelper.LoadComAddIn(ExcelDna.Integration.ExcelComAddIn addIn)
ExcelDna.Integration!ExcelDna.Integration.DnaLibrary.LoadCustomUI()
ExcelDna.Integration!ExcelDna.Integration.DnaLibrary.AutoOpen()
ExcelDna.Integration!ExcelDna.Integration.ExcelIntegration.DnaLibraryAutoOpen()
[Native to Managed Transition]
[Managed to Native Transition]
ExcelDna.Loader!ExcelDna.Loader.IntegrationHelpers.DnaLibraryAutoOpen()
ExcelDna.Loader!ExcelDna.Loader.XlAddIn.XlAutoOpen()
[AppDomain Transition]
I can reproduce this exception by using the CommandBars.dna sample add-in and using Application.RegisterXLL in the Immediate window in the VBE, no XLA required.
Has anyone seen something like this before? Anything that could fix the issue?