protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (_solutionEventsSink != null)
            {
                _solutionEventsSink.Dispose();
                _solutionEventsSink = null;
            }
            if (_runningDocumentsTableEventSink != null)
            {
                _runningDocumentsTableEventSink.Dispose();
                _runningDocumentsTableEventSink = null;
            }
        }
        protected override void Initialize()
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));
            Log.Info("Initializing Sonar Companion.");

            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;

            base.Initialize();

            var componentModel = GetService(typeof (SComponentModel)) as IComponentModel;
            if (componentModel == null)
            {
                throw new InvalidOperationException("ComponentModel is not available");
            }

            var messageBus = componentModel.GetService<IMessageBus>();

            // Compose services that depend on messagebus
            componentModel.GetService<ISonarIssuesService>();
            componentModel.GetService<IVisualStudioAutomationService>();
            componentModel.GetService<SettingsService>();
            componentModel.GetService<AutoRefreshService>();
            componentModel.GetService<OutputWindowService>();

            _solutionEventsSink = new SolutionEventsSink(messageBus, GetService(typeof (SVsSolution)) as IVsSolution);
            _runningDocumentsTableEventSink = new RunningDocumentTableEventSink(GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable, messageBus);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the menu item.
                var menuCommandId = new CommandID(GuidList.guidSonarCompanion_VSIntegrationCmdSet,
                    (int) PkgCmdIDList.cmdidSonarIssues);
                var menuItem = new MenuCommand(ShowToolWindow, menuCommandId);
                mcs.AddCommand(menuItem);

                // Create the command for the tool window
                var toolwndCommandId = new CommandID(GuidList.guidSonarCompanion_VSIntegrationCmdSet,
                    (int) PkgCmdIDList.cmdidSonarIssuesToolWindow);
                var menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandId);
                mcs.AddCommand(menuToolWin);
            }
        }