Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle Visual Studio shutdown properly?

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?

like image 396
sharptooth Avatar asked Mar 14 '26 13:03

sharptooth


1 Answers

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.

like image 67
utkarsh Avatar answered Mar 16 '26 05:03

utkarsh