示例#1
0
        void IDTExtensibility2.OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
        {
            Tweaks.DisposeTweaks(Factory, this, Type);
            RaiseOnDisconnection(RemoveMode, ref custom);

            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 (!Application.IsDisposed)
                {
                    Application.Dispose();
                }
            }
            catch (NetRunTimeSystem.Exception exception)
            {
                NetOffice.DebugConsole.Default.WriteException(exception);
            }
        }
示例#2
0
 private Office.CustomTaskPane CreateCTP(string fullName, string title)
 {
     Office.CustomTaskPane taskPane = null;
     try
     {
         taskPane = TaskPaneFactory.CreateCTP(fullName, title) as Office.CustomTaskPane;
     }
     catch (NetRuntimeSystem.Exception exception)
     {
         string message = String.Format("Unable to create {0}({1}).", fullName, title);
         NetRuntimeSystem.Runtime.InteropServices.COMException wrapperException = new NetRuntimeSystem.Runtime.InteropServices.COMException(message, exception);
         Factory.Console.WriteException(wrapperException);
         OnError(ErrorMethodKind.CTPFactoryAvailable, wrapperException);
     }
     return(taskPane);
 }
示例#3
0
        /// <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);
            }
        }
示例#4
0
        void IDTExtensibility2.OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
        {
            try
            {
                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
                {
                    Tweaks.DisposeTweaks(Factory, this, Type);
                    RaiseOnDisconnection(RemoveMode, ref custom);
                    Utils.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 (!Application.IsDisposed)
                    {
                        Application.Dispose();
                    }
                }
                catch (NetRuntimeSystem.Exception exception)
                {
                    Factory.Console.WriteException(exception);
                }
            }
            catch (Exception exception)
            {
                Factory.Console.WriteException(exception);
                OnError(ErrorMethodKind.OnDisconnection, exception);
            }
        }
示例#5
0
        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);
                    }
                }

                try
                {
                    foreach (var item in OpenFormRegions)
                    {
                        try
                        {
                            IDisposable disposable = item as IDisposable;
                            if (null != disposable)
                            {
                                disposable.Dispose();
                            }
                            else
                            {
                                item.UnderlyingRegion.Dispose();
                            }
                        }
                        catch (NetRuntimeSystem.Exception exception)
                        {
                            NetOffice.DebugConsole.Default.WriteException(exception);
                        }
                    }
                    OpenFormRegions.Clear();
                }
                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);
            }
        }