【发布时间】:2016-04-11 08:24:54
【问题描述】:
我正在开发一个 Visual Studio 插件。我想捕捉打开新解决方案的事件。为了实现这一点,我实现了IVsSolutionEvents 接口并使用AdviseSolutionEvents() 注册它。但是,当我运行 VS 的测试实例并打开解决方案时,没有调用正确的事件方法。
这是我的代码:
public sealed class MyPackage : Package, IVsSolutionEvents
{
// ...
protected override void Initialize()
{
base.Initialize();
IVsSolution solution = GetService(typeof(SVsSolution)) as IVsSolution;
uint cookie = 0;
solution.AdviseSolutionEvents(this, out cookie);
}
// ...
public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
{
MessageBox.Show("Opened a solution!");
return VSConstants.S_OK;
}
}
为什么从未调用过OnAfterOpenSolution()?
【问题讨论】:
标签: c# visual-studio-2015 visual-studio-extensions