/// <summary>
        ///		Called during Outlook startup.
        /// </summary>
        /// <remarks>
        ///		Should not be called from code.
        /// </remarks>
        /// <param name="application">The Outlook application.</param>
        /// <param name="connectMode">The startup type.</param>
        /// <param name="addInInst">This addin.</param>
        /// <param name="custom">Any custom arguments passed to Outlook.</param>
        public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            addInInstance = addInInst;
            System.Runtime.InteropServices.RegistrationServices reg = new System.Runtime.InteropServices.RegistrationServices();
            string progid = reg.GetProgIdForType(this.GetType());

            manager = new OutlookUIManager((RlOutlook.Application)application, this, progid);
            manager.OutlookClosed += new OutlookEventHandler(OnOutlookClosed);

            if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
            {
                OnStartupComplete(ref custom);
            }
        }
        /// <summary>
        ///		Disposes of the addin, the UI manager and anything else that needs releasing.
        /// </summary>
        /// <remarks>
        ///		It is safe to call this multiple times.
        /// </remarks>
        public void Dispose()
        {
            if (addInInstance != null)
            {
#if (COMRELEASE)
                System.Runtime.InteropServices.Marshal.ReleaseComObject(addInInstance);
#endif
                addInInstance = null;
                manager.Dispose();
                manager = null;
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }