unable to register plugin, HRESULT = -2146234076

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

unable to register plugin, HRESULT = -2146234076
 
Stan S




Posts: 184
Joined: 2007-09-04
On a certain computer of our users, ADX plugins just won't register. I created a sample plugin with no logic at all (intercepting Send events of outlook), HRESULT would be the same.
(tried per-machine and per-user, with or without elevation)

Here's the log

Add-in Express Registrator Log File: 03/18/2016 13:40:21

Installation directory: C:\windows\Installer\
Registrator version: 8.0.4330.0
Operating System: Microsoft Windows 7 Professional Service Pack 1 (build 7601), 64-bit
Process Owner: Administrator
Command Line: "C:\windows\Installer\MSI3778.tmp" /install="C:\Program Files (x86)\Default Company\TestOutlookSendEvent\TestOutlookSendEvent.dll" /privileges=admin
Run 'As Administrator': Yes
Process Elevated: Yes
Integrity Level: High
UAC (User Account Control): On
--------------------------------------------------------------
13:40:21 0192 Starting the add-in registration process.
13:40:21 0192 Loading mscoree.dll
13:40:21 0192 Success.
13:40:21 0192 .NET Framework installation directory:
13:40:21 0192 The latest version of .NET Framework: 'v4.0.30319'
13:40:21 0192 Loading CLR: v4.0.30319.
13:40:21 0192 Calling CLRCreateInstance method.
13:40:21 0192 Success.
13:40:21 0192 Calling GetRuntime method.
13:40:21 0192 Success.
13:40:21 0192 Checking if the hosting API of .NET Framework v4.0 beta is installed.
13:40:21 0192 The hosting API is up to date.
13:40:21 0192 Calling GetInterface method for the CorRuntimeHost interface.
13:40:21 0192 Success.
13:40:21 0192 Starting CLR...
13:40:21 0192 Success.
13:40:21 0192 Getting the CLR version.
13:40:21 0192 The CLR v4.0.30319 has been initialized successfully.
13:40:21 0192 Creating a new domain setup.
13:40:21 0192 Success.
13:40:21 0192 The 'shadow copy' is disabled.
13:40:21 0192 Creating a new application domain.
13:40:21 0192 Success.
13:40:21 0192 Getting the base directory for the domain.
13:40:21 0192 Success. The directory is 'C:\Program Files (x86)\Default Company\TestOutlookSendEvent\'.
13:40:21 0192 Searching for the Add-in Express core library.
13:40:21 0192 Success. The 'AddinExpress.MSO.2005.dll' file is found.
13:40:21 0192 Creating an instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
13:40:21 0192 Assembly identity is 'AddinExpress.MSO.2005'.
13:40:21 0192 The add-in registration process is completed with HRESULT = -2146234076.
Posted 18 Mar, 2016 13:56:05 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Stan,

-2146234076 stands for BadImageFormatException. It looks like you build your add-in for the x64 platform.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Mar, 2016 09:35:26 Top
Stan S




Posts: 184
Joined: 2007-09-04
Hello Andrei,

It is not the case. I got back to the problematic computer and doublechecked everything. They have Office 32bit on 64bit system; if I deploy a test setup compiled for 32bit only or for AnyCPU (just a new project without any logic) I am getting that error. I checked everything with corflags, there's no doubt that I've deployed 32bit assemblies.
Posted 22 Mar, 2016 15:12:02 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Stan,

BadImageFormatException occurs in these scenarios: when loading a 32bit assembly in a 64bit process and when loading a 64bit assembly in a 32bit process. Since adxregistrator.exe is 32bit, the exception means your add-in is 64bit.

The code generating the exception is this (adxregistrator.cpp):

		bstrAssembly = assemblyIdentity; 
		bstrClass = _T("AddinExpress.Deployment.ADXRegistrator");
		
		WriteToLog(L"Creating an instance of the '%s' class.", bstrClass);
		WriteToLog(L"Assembly identity is '%s'.", bstrAssembly);

		IfFailGo(m_pLocalDomain->CreateInstance(bstrAssembly, bstrClass, &pObjClassHandle));

		WriteToLog(L"Success.", L"");
		WriteToLog(L"Unwrapping the instance of the '%s' class.", bstrClass);



Andrei Smolin
Add-in Express Team Leader
Posted 23 Mar, 2016 08:48:29 Top
Stan S




Posts: 184
Joined: 2007-09-04
Hello Andrei,

I suspected that .NET is somehow damaged at that machine, and advised the customer to switch to 64bit MS Office.
If they do, however, looks like your code requires the DLL to be compiled for AnyCPU; we're going to run into the same problem. Is there a better way to register x64-only plugin with ADX?

Stan
Posted 23 Mar, 2016 10:35:15 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Stan,

Compiling for AnyCPU allows your code to be run as 64bit when loaded in a 64bit Office. I don't see how this will end with the same problem. BTW, I wonder if the customer has several Office versions installed. Or, at least programs from different Office versions.

Stan S writes:
Is there a better way to register x64-only plugin with ADX?


Please see https://www.add-in-express.com/creating-addins-blog/2015/02/25/creating-bit-specific-office-addin/.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Mar, 2016 02:01:54 Top