Addin works fine with Excel but fails silently when debugging from VS2017

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

Addin works fine with Excel but fails silently when debugging from VS2017
 
Maurice Calvert




Posts: 95
Joined: 2008-09-12
Environment: Windows 10 Pro 10.0.18363 / .Net 4.7.2 / VS2017 15.9.21 / adxnet-v904-b4644 / Excel 64bit 16.0.12624.20278

I can't debug my addin project, it doesn't load from Visual Studio.

Here's what I'm doing to reproduce
- Unregister addin from VS, just to be sure, it disappears from the registry (Microsoft/Office/16/Excel...)
- Register addin from VS. Addin appears in registry as expected, LoadBehavior=3.
*NO* Adxregistrator.log produced!
- Start Excel. Addin loads, everything's OK
ADXLOADER.LOG
Add-in Express Loader Log File: 03/31/2020 21:46:38:281
Startup directory: D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\
Loader version: 9.4.4644.0
Operating System: Microsoft Windows 10 Professional (build 18363), 64-bit
Process Owner: Administrator
Command Line: "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
Run 'As Administrator': No
Process Elevated: No
Integrity Level: Medium
UAC (User Account Control): On
------------------------------------------------------------------------
21:46:38:289 3256 10796 Start.
21:46:38:290 3256 10796 The host's version is 16.0.12624.20320
21:46:38:290 3256 10796 Creating a new instance of the add-in loader.
21:46:38:290 3256 10796 Loading mscoree.dll
21:46:38:290 3256 10796 INFO: Assembly codebase - D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\GeodesiX.dll.
21:46:38:381 3256 10796 INFO: Assembly version - 4.2.0.0.
21:46:38:381 3256 10796 Success.
21:46:38:381 3256 10796 Loading the configuration from the system registry.
21:46:38:382 3256 10796 Getting the latest CLR version.
21:46:38:382 3256 10796 The latest CLR version is 'v4.0.30319'.
21:46:38:382 3256 10796 The configuration has been loaded successfully.
21:46:38:382 3256 10796 Runtime version: v4.0.30319.
21:46:38:382 3256 10796 Assembly name: GeodesiX, PublicKeyToken=915247C7FF1D355B.
21:46:38:382 3256 10796 Class name: GeodesiX.GeodesiXEXL.
21:46:38:382 3256 10796 Registry key: CLSID\{B3933D3D-FA7A-48E4-A1A3-97EE6331C22F}.
21:46:38:382 3256 10796 Attempting to create a new instance of the managed add-in class: CLR - v4.0.30319
21:46:38:382 3256 10796 Loading CLR: v4.0.30319.
21:46:38:383 3256 10796 Calling CLRCreateInstance method.
21:46:38:383 3256 10796 Success.
21:46:38:383 3256 10796 Calling GetRuntime method.
21:46:38:383 3256 10796 Success.
21:46:38:383 3256 10796 Checking if the hosting API of .NET Framework v4.0 beta is installed.
21:46:38:397 3256 10796 The hosting API is up to date.
21:46:38:397 3256 10796 Calling SetDefaultStartupFlags method.
21:46:38:397 3256 10796 Success.
21:46:38:397 3256 10796 Calling GetInterface method for the CorRuntimeHost interface.
21:46:38:397 3256 10796 Success.
21:46:38:397 3256 10796 Starting CLR...
21:46:38:397 3256 10796 Success.
21:46:38:397 3256 10796 Getting the CLR version.
21:46:38:397 3256 10796 The CLR v4.0.30319 has been initialized successfully.
21:46:38:397 3256 10796 Creating a new domain setup.
21:46:38:398 3256 10796 Success.
21:46:38:398 3256 10796 Getting the add-in directory.
21:46:38:398 3256 10796 Success. The directory is 'D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\'
21:46:38:400 3256 10796 The 'shadow copy' is enabled.
21:46:38:400 3256 10796 Creating a new application domain.
21:46:38:405 3256 10796 Success.
21:46:38:405 3256 10796 Creating an instance of the managed class. Assembly identity: 'GeodesiX, PublicKeyToken=915247C7FF1D355B'
21:46:38:771 3256 10796 Success.
21:46:38:771 3256 10796 Unwrapping the managed class.
21:46:38:776 3256 10796 Success.
21:46:38:776 3256 10796 Querying the add-in extensibility.
21:46:38:776 3256 10796 Success.
21:46:38:776 3256 10796 Querying the custom task panes.
21:46:38:776 3256 10796 Success.
21:46:38:776 3256 10796 Querying the ribbon extensibility.
21:46:38:776 3256 10796 Success.
21:46:38:776 3256 10796 Querying the form regions.
21:46:38:776 3256 10796 Success.
21:46:38:776 3256 10796 Querying the encryption provider.
21:46:38:777 3256 10796 The 'EncryptionProvider' interface is not supported.
21:46:38:777 3256 10796 Getting the dispid of the 'Dispose' method.
21:46:38:780 3256 10796 Success.
21:46:38:781 3256 10796 Getting the dispid of the 'InitializeLoaderService' method.
21:46:38:781 3256 10796 Success.
21:46:38:781 3256 10796 Invoking the 'InitializeLoaderService' method.
21:46:38:781 3256 10796 Success.
21:46:38:781 3256 10796 The instance of the managed add-in class has been created successfully.


- Close Excel
- Start debugging in VS. Addin doesn't load, registry LoadBehavior=2, silently

- Copy AddinExpress.MSO.2005.dll and adxregistrator.exe to root of addin project, copy-if-newer
- Register manually:
cd D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug
adxregistrator.exe /install="geodesix.dll" /privileges=user

Adxregistrator.log produced correctly:
Add-in Express Registrator Log File: 03/31/2020 21:53:41
Installation directory: D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\
Registrator version: 9.4.4644.0
Operating System: Microsoft Windows 10 Professional (build 18363), 64-bit
Process Owner: Administrator
Command Line: adxregistrator.exe /install="geodesix.dll" /privileges=user
Run 'As Administrator': Yes
Process Elevated: Yes
Integrity Level: High
UAC (User Account Control): On
--------------------------------------------------------------
21:53:41 0524 Starting the add-in registration process.
21:53:41 0524 Loading mscoree.dll
21:53:41 0524 Success.
21:53:41 0524 .NET Framework installation directory:
21:53:41 0524 The latest version of .NET Framework: 'v4.0.30319'
21:53:41 0524 Loading CLR: v4.0.30319.
21:53:41 0524 Calling CLRCreateInstance method.
21:53:41 0524 Success.
21:53:41 0524 Calling GetRuntime method.
21:53:41 0524 Success.
21:53:41 0524 Checking if the hosting API of .NET Framework v4.0 beta is installed.
21:53:41 0524 The hosting API is up to date.
21:53:41 0524 Calling GetInterface method for the CorRuntimeHost interface.
21:53:41 0524 Success.
21:53:41 0524 Starting CLR...
21:53:41 0524 Success.
21:53:41 0524 Getting the CLR version.
21:53:41 0524 The CLR v4.0.30319 has been initialized successfully.
21:53:41 0524 Creating a new domain setup.
21:53:41 0524 Success.
21:53:41 0524 Getting the add-in directory.
21:53:41 0524 Success. The directory is 'D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\'
21:53:41 0524 The 'shadow copy' is disabled.
21:53:41 0524 Creating a new application domain.
21:53:41 0524 Success.
21:53:41 0524 Getting the base directory for the domain.
21:53:41 0524 Success. The directory is 'D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\'.
21:53:41 0524 Searching for the Add-in Express core library.
21:53:41 0524 Success. The 'AddinExpress.MSO.2005.dll' file is found.
21:53:41 0524 Creating an instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
21:53:41 0524 Assembly identity is 'AddinExpress.MSO.2005'.
21:53:41 0524 Success.
21:53:41 0524 Unwrapping the instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
21:53:41 0524 Success.
21:53:41 0524 Calling the managed registration procedure (DISPID = 1610743823).
21:53:41 1052 32 bits. The 'HKCU\Software\Microsoft\Office\Excel\AddIns\GeodesiX.Addin' registry key was created successfully for the 'GeodesiX.GeodesiXEXL' class: LoadBehavior=3
21:53:41 1052 32 bits. The 'HKCU\CLSID\{b3933d3d-fa7a-48e4-a1a3-97ee6331c22f}\InprocServer32' registry key was created successfully for the 'GeodesiX.GeodesiXEXL' class: D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\adxloader.dll
21:53:41 1052 64 bits. The 'HKCU\Software\Microsoft\Office\Excel\AddIns\GeodesiX.Addin' registry key was created successfully for the 'GeodesiX.GeodesiXEXL' class: LoadBehavior=3
21:53:41 1052 64 bits. The 'HKCU\CLSID\{b3933d3d-fa7a-48e4-a1a3-97ee6331c22f}\InprocServer32' registry key was created successfully for the 'GeodesiX.GeodesiXEXL' class: D:\Projects\GeodesiX\4.2.0\GeodesiX\bin\Debug\adxloader64.dll
21:53:41 0524 Registration success.
21:53:41 0524 The add-in registration process is completed with HRESULT = 0.


Addin continues to work from Excel but as soon as I try to debug it reverts to LoadBehavior=2, silently.

Now I've probably done something wrong (it worked last week); any ideas on how to determine what's wrong would be most welcome.
Posted 31 Mar, 2020 15:08:41 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Maurice,

Maurice Calvert writes:
*NO* Adxregistrator.log produced!


This is expected: adxregistrator.exe isn't used when you register the add-in from the Visual Studio IDE.

Maurice Calvert writes:
Excel 64bit 16.0.12624.20278


Can it be that you use the Microsoft Store version of Office? Have a look at https://www.add-in-express.com/creating-addins-blog/2019/02/27/office-from-store-issues/.

Make sure you start VS via the Run as administrator option when registering the add-in. Make sure Excel started non-elevated when using the way that you typically use to start it.

Also, you don't need to start adxregistrator.exe elevated to register a per-user add-in: user permissions should be enough.


Andrei Smolin
Add-in Express Team Leader
Posted 01 Apr, 2020 01:05:03 Top
Maurice Calvert




Posts: 95
Joined: 2008-09-12
Still can't get it to load from VS debug (but attaching the debugger to an excel with the addin running works fine).
- Elevated or not doesn't seem to change anything
- Runtime version checked
User added an image
- Definitely not MS Store
User added an image

When starting from VS2017 debug, Excel seems to open the addin and then almost immediately (in ~8mS) gives up and sets LoadBehavior=2:
User added an image

How can I diagnose what's happening when launching Excel from VS2017 Debug?
Posted 01 Apr, 2020 07:09:35 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Thank you for these details.

Maurice Calvert writes:
How can I diagnose what's happening when launching Excel from VS2017 Debug?


Does starting Excel to debug the add-in update adxloader.log?

Make sure you don't have your add-in installed. Also, make sure it isn't registered in HKLM.


Andrei Smolin
Add-in Express Team Leader
Posted 01 Apr, 2020 07:22:10 Top
Maurice Calvert




Posts: 95
Joined: 2008-09-12
Thanks for bearing with me on this one Andrei >;-)
- Unregistered from VS2017
- adxregistrator.exe /uninstall="geodesix.dll" /privileges=user (just to be sure)
- Checked nothing left in Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins
- Searched registry starting at HKLM, first occurrence of "Geodesix" found in HKUSERS, so nothing in HKLM either

- VS2017 Adx register. No file produced (I'm watching every file with https://en.wikipedia.org/wiki/Everything_(software))
- Start debugging. Excel starts, no addin loaded, no files created, not a sausage

- Reset LoadBehavior=3
- Start Excel, addin loads nicely
- VS2017 attach process, debugging works perfectly

User added an image
Posted 01 Apr, 2020 10:12:57 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Maurice,

No problem!


Andrei Smolin
Add-in Express Team Leader
Posted 01 Apr, 2020 10:21:35 Top
Maurice Calvert




Posts: 95
Joined: 2008-09-12
Erm, yes, but there *is* a problem:
When I start debugging from VS2017, the addin doesn't load.
I can indeed debug by attaching the debugger to a running Excel instance, but that's not how it's supposed to work.

When I start debugging in VS2017, the addin doesn't load.
It should.
How can I find out why it doesn't load?
Posted 01 Apr, 2020 15:04:54 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Maurice,

Ah, I see.

Maurice Calvert writes:
When I start debugging from VS2017, the addin doesn't load.


Is adxloader.log updated in this case?


Andrei Smolin
Add-in Express Team Leader
Posted 02 Apr, 2020 02:38:30 Top
Maurice Calvert




Posts: 95
Joined: 2008-09-12
No, adxloader.log is not created when VS2017->Start debug.

Excel starts, no addins, no messages, no files created. VS2017 debugger is running but not attached.
Posted 02 Apr, 2020 02:48:55 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Is the add-in installed or registered from the IDE?

If both, uninstall and unregister it, start Excel to make sure you have no traces of the add-in in the Excel UI, register it and debug it.


Andrei Smolin
Add-in Express Team Leader
Posted 02 Apr, 2020 02:52:24 Top