/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Logger = new ActivityLogger(this); Logger.LogInfo("Entering initializer for: {0}", this.ToString()); base.Initialize(); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null == mcs) { Logger.LogInfo("Could not get OleMenuCommandService"); return; } var dropdownService = new DropdownService(mcs); // Get VS Automation object var dte = (EnvDTE.DTE)GetGlobalService(typeof(EnvDTE.DTE)); // Get solution solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2; if (solution != null) { // Register for solution events solution.AdviseSolutionEvents(this, out solutionEventsCookie); } // Get selection monitor ms = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection; if (ms != null) { // Remember debugging UI context cookie for later ms.GetCmdUIContextCookie(VSConstants.UICONTEXT.Debugging_guid, out debuggingCookie); // Register for selection events ms.AdviseSelectionEvents(this, out selectionEventsCookie); } var fileChangeService = ServiceProvider.GlobalProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; switcher = new StartupProjectSwitcher(dropdownService, dte, fileChangeService, Logger); }