How can my add-in detect when a solution is loaded? I know there must be some event somewhere in the DTE model, but I can't find it. My add-in loads when Visual Studio loads, but it depends on a solution being open. I don't want to make it a solution add-in until MS loses their sick fixation on COM, as solution add-ins have to be COM components.
+2
A:
Here's how to register for event handling using C#
_solutionEvents = _applicationObject.Events.SolutionEvents;
_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionOpened);
_solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(SolutionClosed);
Also note, that when user opens Visual Studio by double clicking on solution file, you won't get event for solution opening. You should check whether _applicationObject.Solution is not null in OnStartupComplete method to handle this situation correctly.
Juozas Kontvainis
2009-02-23 15:05:40
A:
You have in the DTE2 class a property called Events
it gives a lots kind of events, for what you need you have to use:
DTE2 _applicationObject
_applicationObject.Events.SolutionEvents.Opened+=new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
pablito
2009-02-23 15:22:39