/// <summary> /// Occurs whenever an add-in is unloaded from MS Office /// </summary> /// <param name="removeMode">An ext_DisconnectMode enumeration value that informs an add-in why it was unloaded.</param> /// <param name="custom">An empty array that you can use to pass host-specific data for use after the add-in unloads</param> protected override void HandleOnDisconnection(ext_DisconnectMode removeMode, ref Array custom) { try { RaiseOnDisconnection(removeMode, ref custom); Utils.Dispose(); } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } foreach (ITaskPane item in TaskPaneInstances) { try { item.OnDisconnection(); } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } } foreach (var item in TaskPanes) { try { if (null != item.Pane && !item.Pane.IsDisposed) { item.Pane.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } } try { if (null != TaskPaneFactory && false == TaskPaneFactory.IsDisposed) { TaskPaneFactory.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } try { if (null != RibbonUI) { RibbonUI.Dispose(); RibbonUI = null; } } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } try { if (!Application.IsDisposed) { Application.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } try { CleanUp(); } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } }
void NetOffice.Tools.Native.IDTExtensibility2.OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom) { try { try { RaiseOnDisconnection(RemoveMode, ref custom); Tweaks.DisposeTweaks(Factory, this, Type); Utils.Dispose(); } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); } foreach (ITaskPane item in TaskPaneInstances) { try { item.OnDisconnection(); } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); } } foreach (var item in TaskPanes) { try { if (null != item.Pane && !item.Pane.IsDisposed) { item.Pane.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); } } try { if (null != TaskPaneFactory && false == TaskPaneFactory.IsDisposed) { TaskPaneFactory.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); } try { if (null != RibbonUI) { RibbonUI.Dispose(); RibbonUI = null; } } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); } try { if (!Application.IsDisposed) { Application.Dispose(); } } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); } } catch (NetRuntimeSystem.Exception exception) { NetOffice.DebugConsole.Default.WriteException(exception); OnError(ErrorMethodKind.OnDisconnection, exception); } }