I'm trying to reload add-in to handle my own update runtime (using click once deployment API, but to provide silend updates)
But I've stucked on reloading add-in. My current task is just simple unload and reload add-in. What I found was similar to this:
private void Reload()
{
try
{
COMAddIns comAddIns = Globals.ThisAddIn.Application.COMAddIns;
COMAddIn addIn =
comAddIns.Cast<COMAddIn>().FirstOrDefault(addin => string.Equals(addin.Description, "OutlookAddIn1", StringComparison.OrdinalIgnoreCase));
if (addIn != null)
{
addIn.Connect = false;
addIn.Connect = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
But this simple crashes on:
addIn.Connect = false;
I tried put this inside additonal try/catch block but it is not working. While calling
Connect = false
I have ThreadAbortException
, that I cannot prevent to happen.
I would simple disable and enable add-in from code, at this moment which I cannot achieve.