How to troubleshoot the COM Add-ins loading issues
1. What is the unmanaged COM Add-ins loading process?
Here is a COM Add-in registry example.
[HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\AddIns\UnmanagedAddin.Connect]
"FriendlyName"="UnmanagedAddin"
"Description"="Composed in ATL 8.0"
"LoadBehavior"=dword:00000003
HKEY_CURRENT_USER: this is user level COM-Addin
Excel: This is an Excel COM Addin
UnmanagedAddin.Connect: This is progid of the COM Add-in
LoadBehavior: control how the Add-in will be loaded.
You may refer the link below about LoadBehavior
https://support.microsoft.com/?id=824251
a) Check the registry for the available COM Add-ins
HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\AddIns\
Or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Excel\Addins\
HKEY_CURRENT_USER one: stored the COM Add-ins for the current user only. (i.e. when we installed the Add-in, we checked “just for me”, user level)
HKEY_LOCAL_MACHINE one: stored the COM Add-ins for all users. (i.e. when we installed the Add-in, we checked “Everyone”, machine level)
b) Found an entry of Add-in (UnmanagedAddin.Connect) of LoadBehavior 3.
c) Attempt to locate the COM DLL of progid “UnmanagedAddin.Connect”(Common COM Load procedure)
i. Found HKEY_CLASSES_ROOT\UnmanagedAddin.Connect\CurVer
Default Value is “UnmanagedAddin.Connect.1"
ii. Found “HKEY_CLASSES_ROOT\UnmanagedAddin.Connect.1\CLSID”
Default Value is “{F51126A7-472D-4D3D-A011-8D1467F6BAFD}”
iii. Located the registry key below.
HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}]
@="Connect Class"
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}\InprocServer32]
@="c:\\users\\username\\documents\\visual studio 2005\\projects\\comaddins\\unmanagedaddin\\debug\\UnmanagedAddin.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}\ProgID]
@="UnmanagedAddin.Connect.1"
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}\Programmable]
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}\TypeLib]
@="{A5A5FD6A-2A19-4DB6-AB8F-51735C47CDAD}"
[HKEY_CLASSES_ROOT\CLSID\{F51126A7-472D-4D3D-A011-8D1467F6BAFD}\VersionIndependentProgID]
@="UnmanagedAddin.Connect"
iv. Loaded the DLL with Win32 LoadLibrary API.
2. What is the managed COM Add-ins loading process?
a) The steps are similar except for step 1 c) iii
[HKEY_CLASSES_ROOT\CLSID\{5E5E6110-C49E-41FD-891B-7693500F0EC4}]
@="ManagedAddin.Connect"
[HKEY_CLASSES_ROOT\CLSID\{5E5E6110-C49E-41FD-891B-7693500F0EC4}\Implemented Categories]
[HKEY_CLASSES_ROOT\CLSID\{5E5E6110-C49E-41FD-891B-7693500F0EC4}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\CLSID\{5E5E6110-C49E-41FD-891B-7693500F0EC4}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="ManagedAddin.Connect"
"Assembly"="ManagedAddin, Version=1.0.2552.27634, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Users/username/Documents/Visual Studio 2005/Projects/COMAddins/ManagedAddin/bin/Debug/ManagedAddin.dll"
b) In a managed scenario, the mscoree.dll will be loaded instead of the Add-in DLL directly. Then, it is the mscoree.dll which loads the managed Add-in DLL.
3. General troubleshooting steps are based on the COM Add-ins Load Process.
a) Disable all the other COM Add-ins and restart Office Product
b) Go through the COM Add-in Load Procedure.
i. If the registry key existed (refer to 1 a)), did the LoadBehavior set to 3?
ii. Follow the steps that how COM DLL is Loaded (refer to 1 c))
4. Some general approaches.
a) By default the .NET CAS (Code Access Security) setting is OK for COM Add-ins, but this is a new security check added by .NET. When you develop managed COM Add-ins, you may try to add “Full Trust” permission set for the Add-in DLL when you have no idea.
https://msdn2.microsoft.com/en-us/library/930b76w0.aspx
b) Embrace your code in a “try…catch” block and write Log when error occurred.
c) Isolate the problem.
Comment out all of your code, and put the simple code as below in your OnConnect method. Once this is called, we should consider the Add-in loading to be OK.
e.g.
STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/ )
{
::MessageBoxW(NULL,L"Hello",L"Test Dialog",MB_ICONINFORMATION);
return S_OK;
}
d) Leverage the tools Filemon/Regmon to track the registry/file security setting.
https://www.microsoft.com/technet/sysinternals/utilities/filemon.mspx
https://www.microsoft.com/technet/sysinternals/utilities/regmon.mspx
Comments
Anonymous
May 12, 2007
MSN I NIIPET <a href="http://msn.com">MSN</a>Anonymous
April 10, 2008
Does Office do any logging to explain why it changes the LoadBehavior from 3 to 2?Anonymous
January 04, 2009
This link to a blog entry on the same topic has some additional suggestions: http://blogs.msdn.com/vsod/archive/2008/04/22/Troubleshooting-com-add-in-load-failures.aspxAnonymous
January 09, 2009
The comment has been removed