In Visual Studio Extension, how do I respond to "Open Folder" as well as "Open Solution"?

My Visual Studio Extension responds to opening a solution through IVsSolutionEvents.OnAfterOpenSolution() .

Visual Studio 2017 introduced “Open Folder” as an alternative to “Open Solution,” but when you open the folder, IVsSolutionEvents.OnAfterOpenSolution() doesn’t fire. (And neither of the other events in IVsSolutionEvents , nor any of the events in IVsSolutionLoadEvents .)

How does my extension know when a folder opens, not a solution?

+5
source share
1 answer

You should use the IVsSolutionEvents7.OnAfterOpenFolder Method , which was added for Visual Studio 2017.

Notifies listeners that the folder is open.

 public void OnAfterOpenFolder (string folderPath); 

Since this is a native COM interface, you must also make sure that the COM implementation class is visible (through the ComVisible attribute, which you can set the assembly, class, base class, etc.).

+6
source

Source: https://habr.com/ru/post/1272076/


All Articles