This documentation is archived and is not being maintained.

How to: Exit the IDE

Visual Studio 2008

It is important to provide code to make sure that the IDE exits properly, because you cannot be sure what state the integrated development environment (IDE) is in when the user or the system closes the IDE. Provide code to perform the following actions:

  • De-allocate resources.

  • Save information.

  • Handle potential exceptions.

  • Stop external process debugging.

  • Perform any other custom clean-up procedures before the IDE closes.

The following example stops the IDE debugger if it is running. This ensures that any external processes that are using the debugger close along with the IDE.

private void IDEShutDown(EnvDTE.DTE dte)
    if (dte != null)
        // Add code to dispose of custom objects, save files, 
        // and perform any clean-up tasks.

        // Stop external process debugging.
        if (dte.Mode == EnvDTE.vsIDEMode.vsIDEModeDebug)
        // Close the DTE object.

This example requires the following references:

  • Microsoft Development Environment 8.0.

  • DTEProvider 1.0 Type Library in the C:\Program Files\Common Files\Microsoft Shared\VSTA\9.0\x86 directory.