我的Visual Studio Extension通過IVsSolutionEvents.OnAfterOpenSolution()
響應開放的解決方案。在Visual Studio擴展中,如何響應「打開文件夾」以及「打開解決方案」?
Visual Studio 2017引入"Open Folder"作爲「打開解決方案」的替代方法,但是當您打開文件夾時,IVsSolutionEvents.OnAfterOpenSolution()
不會觸發。 (在IVsSolutionEvents
中也沒有發生任何其他事件,也沒有在IVsSolutionLoadEvents
中發生任何事件。)
我的擴展程序如何才能知道與解決方案相對的文件夾何時打開?
您是否在尋找IVsSolutionEvents7 :: OnAfterOpenFolder? https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.interop.ivssolutionevents7?view=visualstudiosdk 2017 –
@SimonMourier:看起來很完美,但是當我實現它並通過我的實現對象到'IVsSolution.AdviseSolutionEvents()',沒有任何'IVsSolutionEvents7'事件觸發。該對象還實現了'IVsSolutionEvents',並且這些事件發生。有任何想法嗎...? – RichieHindle
不,我想這是唯一的方法。一些VS dll實現該接口就像那樣(例如Microsoft.VisualStudio.Shell.UI.Internal,類Microsoft.VisualStudio.PlatformUI.StartPageToolWindowPane)。您可以嘗試暫時實現ICustomQueryInterface,只是爲了檢查它是否請求該接口。 –