简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM