繁体   English   中英

解决方案加载时的Visual Studio加载项挂钩

[英]Visual Studio add-in hook on solution load

我正在尝试编写Visual Studio的加载项,每次加载解决方案时都需要运行该加载项。 最终我希望将它作为一个解决方案加载项,以便它只针对需要它的解决方案运行,但我想知道是否有任何方法可以在用户加载解决方案时使用我的加载项挂钩?

谢谢。

VCProjectEngineEvents SolutionLoaded事件。

编辑:我只能希望别人可以提出他们可以发布的样本 - 我所拥有的唯一相关代码是我无法发布的内容。

您可以使用Saver加载项源代码作为示例(它是Tabs Studio加载项的加载项):
在Saver.cs中,您订阅了以下活动:

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);

在SolutionEventsSink.cs中是实际的解决方案事件处理程序:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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