Question

I'm trying to handle Visual Studio shutdown in my add-in. The problem is once the shutdown has started various DTE objects methods will no longer work and will instead trigger COMExceptions with E_FAIL error code and so the add-in can no longer work properly.

I therefore need to somehow detect the moment when the shutdown is initiated. There're EnvDTE.DTE.Events.SolutionEvents and EnvDTE.DTE.Events.DTEEvents classes but all the events inside them are marked "infrastructure only" so it looks like I shouldn't subscribe to them.

What's the right way to detect that Visual Studio has started to shut down and so DTE is no longer fully usable?

Was it helpful?

Solution

Visual Studio provides QueryClose method to handle the VS shut down in VS packages.

To use this, override this method in your Package class, and do the actions you want to perform during the shutdown.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top