Dela via


How to: Exit the IDE

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.

Example

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)
        {
            dte.Debugger.Stop(true);
        }
    
        // Close the DTE object.
        dte.Quit();
    }
}

Compiling the Code

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.

See Also

Tasks

How to: Start the IDE

How to: Enable Non-Destructive Debugging for Add-Ins

Walkthrough: Incorporating the IDE for a Managed Object Model

Concepts

Incorporating the Integrated Development Environment

Configuring the IDE

Integrating Help into the IDE

Add-In Debugging

Deploying the IDE and Runtime

Other Resources

Visual Studio Tools for Applications 2.0