Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 解决方案加载时的Visual Studio加载项挂钩_C#_Visual Studio_Hook_Solution - Fatal编程技术网

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

C# 解决方案加载时的Visual Studio加载项挂钩,c#,visual-studio,hook,solution,C#,Visual Studio,Hook,Solution,我正在尝试为VisualStudio编写一个插件,它需要在每次加载解决方案时运行。最终,我希望将其作为一个解决方案外接程序,以便它只为需要它的解决方案运行,但我想知道是否有任何方法可以让我的外接程序钩住加载解决方案的用户 谢谢。VCProjectEngineeEvents SolutionLoaded事件 编辑:我只希望其他人能提供一个他们可以发布的示例-我仅有的相关代码是我无法发布的。VCProjectEngineeEvents SolutionLoaded事件 编辑:我只希望其他人能提供一个

我正在尝试为VisualStudio编写一个插件,它需要在每次加载解决方案时运行。最终,我希望将其作为一个解决方案外接程序,以便它只为需要它的解决方案运行,但我想知道是否有任何方法可以让我的外接程序钩住加载解决方案的用户

谢谢。

VCProjectEngineeEvents SolutionLoaded事件

编辑:我只希望其他人能提供一个他们可以发布的示例-我仅有的相关代码是我无法发布的。

VCProjectEngineeEvents SolutionLoaded事件

编辑:我只希望其他人能提供一个他们可以发布的示例-我仅有的相关代码是我无法发布的。

您可以使用它作为示例,它是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
例如,它是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

太好了!不过,我对C有点不熟悉,所以我可以麻烦你举一个如何注册钩子的例子吗?谢谢,太好了!不过,我对C有点不熟悉,所以我可以麻烦你举一个如何注册钩子的例子吗?谢谢