coppro
coppro

Reputation: 14516

Visual Studio add-in hook on solution load

I'm trying to write an add-in for Visual Studio that needs to be run every time a solution is loaded. Eventually I hope to make it a solution add-in so that it only runs for solutions that need it, but I'm wondering if there's any way to have my add-in hook on the user loading a solution?

Thanks.

Upvotes: 1

Views: 1958

Answers (2)

Sergey Vlasov
Sergey Vlasov

Reputation: 27890

You can use Saver add-in source code as an example (it is an add-in for the Tabs Studio add-in):
In Saver.cs you subscribe for events:

solutionEventsSink = new SolutionEventsSink(orderController);
System.IServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(dte as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
vsSolution = ServiceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsSolution)) as Microsoft.VisualStudio.Shell.Interop.IVsSolution;
vsSolution.AdviseSolutionEvents(solutionEventsSink, out sinkCookie);

In SolutionEventsSink.cs are actual solution events handlers:

class SolutionEventsSink : Microsoft.VisualStudio.Shell.Interop.IVsSolutionEvents

Upvotes: 2

Jerry Coffin
Jerry Coffin

Reputation: 490108

The VCProjectEngineEvents SolutionLoaded event.

Edit: I can only hope somebody else can come up with a sample they can post -- the only relevant code I have is something I can't post.

Upvotes: 2

Related Questions