开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜