void Compose() { StaticPart.App = App; // store in static property try { Composer = MefComposer.ComposeWithPlugins(this); } catch (Exception ex) { Logger.Log(string.Format("Error loading with plugins: {0}", ex.Message)); if (Composer != null) { Composer.Dispose(); } try { Logger.Log("Loading without plugins."); Composer = MefComposer.ComposeWithoutPlugins(this); } catch (Exception ex2) { Logger.Log(string.Format("Error loading: {0}", ex2.Message)); if (Composer != null) { Composer.Dispose(); } Composer = null; } } }
/// <summary> /// Implements the OnDisconnection method of the IDTExtensibility2 interface. /// Occurs when the Add-in is being unloaded. /// </summary> /// <param name="disconnectMode">Describes how the Add-in is being unloaded.</param> /// <param name="custom">Array of parameters that are host application specific.</param> /// <seealso cref="IDTExtensibility2"/> public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom) { if (Composer != null) { Composer.Dispose(); } Logger.Log("Goodbye!"); }
private void OnShutdown(object sender, ExitEventArgs e) { myComposer.Resolve <ProjectService>().Save(); myComposer.Dispose(); }