【发布时间】:2017-09-27 01:28:05
【问题描述】:
我的 Visual Studio 扩展通过 IVsSolutionEvents.OnAfterOpenSolution() 响应打开解决方案。
Visual Studio 2017 引入了 "Open Folder" 作为“打开解决方案”的替代方案,但是当您打开文件夹时,IVsSolutionEvents.OnAfterOpenSolution() 不会触发。 (IVsSolutionEvents 中的任何其他事件也没有,IVsSolutionLoadEvents 中的任何事件也没有。)
我的扩展程序如何知道文件夹而不是解决方案何时打开?
【问题讨论】:
-
您在寻找 IVsSolutionEvents7::OnAfterOpenFolder 吗? docs.microsoft.com/en-us/dotnet/api/…
-
@SimonMourier:看起来很完美,但是当我实现它并将我的实现对象传递给
IVsSolution.AdviseSolutionEvents()时,IVsSolutionEvents7事件都不会触发。该对象还实现了IVsSolutionEvents,并且这些事件确实会触发。有什么想法...? -
不,我想这确实是唯一的方法。一些 VS dll 就像那样实现该接口(例如 Microsoft.VisualStudio.Shell.UI.Internal,Microsoft.VisualStudio.PlatformUI.StartPageToolWindowPane 类)。您可以尝试临时实现 ICustomQueryInterface 以检查它是否甚至请求该接口。
-
@SimonMourier:啊哈!实现 ICustomQueryInterface 显示我需要将
[ComVisible(true)]添加到我的IVsSolutionEvents7定义中。之后(以及更多的 COM 箍跳)现在一切正常 - 谢谢!如果您想从您的评论中创建答案,我很乐意接受它并奖励它(当它符合条件时)。
标签: visual-studio visual-studio-2017 vsix vs-extensibility