/// <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() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); //SolutionEventsListener class from http://stackoverflow.com/questions/2525457/automating-visual-studio-with-envdte // via Elisha http://stackoverflow.com/users/167149/elisha listener = new SolutionEventsListener(); winmgr = Package.GetGlobalService(typeof(IVsUIShellDocumentWindowMgr)) as IVsUIShellDocumentWindowMgr; listener.OnQueryUnloadProject += () => { Debug.WriteLine("HANSELMAN: Before Unload Project!"); comStream = SaveDocumentWindowPositions(winmgr); }; listener.OnAfterOpenProject += () => { int hr = winmgr.ReopenDocumentWindows(comStream); comStream = null; Debug.WriteLine(String.Format("HANSELMAN: After Project Loaded! hr=", hr)); }; base.Initialize(); }