I've been developing the VSTO plugin for Outlook and on some customers' PCs ran into the slow loading issue (which is apparently a chronic disease for all managed office add-ins as CLR loading is counted towards the whole plugin loading time).
I've read about a workaround that there is a possibility to have the VSTO plugin loaded by setting its Connect
property to true from a fast-loading Native COM add-in: https://blogs.msdn.microsoft.com/andreww/2008/04/19/delay-loading-the-clr-in-office-add-ins/
I've implemented it, however even after setting the Connect
property of VSTO add-in to true from the Native add-in it is still not loaded. I have the following code that is executed at OnStartupComplete
:
CComVariant vtItem("VSTOAddInName");
Office::COMAddInsPtr spCOMAddins;
m_spOutlook->get_COMAddIns(&spCOMAddins);
if (spCOMAddins) {
Office::COMAddInPtr spCOMAddIn;
if (spCOMAddins->Item(&vtItem, &spCOMAddIn) == S_OK)
{
spCOMAddIn->put_Connect(VARIANT_TRUE);
// I see this message!
MessageBoxW(NULL, L"Connected flag set", L"Native_Addin", MB_OK);
}
}
return S_OK;
The m_spOutlook is defined as:
Outlook::_ApplicationPtr m_spOutlook;
I see the MessageBox, so I assume that Connect property is set, but the addin still does not load. I've tried to do t with all possible LoadBehavior settings and none of those work. So the question is whether this workaround supposed to work? Maybe I should execute it under a different callback than OnStartupComplete
. It is fine for me tho have the plugin loaded few seconds after outlook start, I just need it loaded and not hit the 1 second startup limit.
I would really appreciate your help!
P.S. The load-once delay-loaded VSTO plugin (LoadBehavior=16) is only a partial solution for me as I need the button in the ribbon to be disabled on certain items, so I need the plugin to be really loaded. Also, sometimes the button is disappeared without any notable reasons and it requires end users to do some magic to get it back which is not an option for me.