Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

OnBeginShutdown Method

Visual Studio .NET 2003

Occurs when the environment is being shut down.

[Visual Basic .NET]
Public Sub OnBeginShutdown( _
   ByVal custom() As Variant _
[Visual Basic 6]
Sub OnBeginShutdown( _
   ByVal custom() As Variant _
HRESULT __stdcall OnBeginShutdown(
   SAFEARRAY** custom
void OnBeginShutdown(
   object[] custom
[JScript .NET]
public function OnBeginShutdown(
   custom : Object[]


An array of Variants that you can use to provide additional data.


OnBeginShutdown is a method that, when its host interface is implemented, acts as an event that occurs while the environment is being shut down.

The OnBeginShutdown event occurs when a host application begins its shutdown routines; that is, when a application closes while the Add-in is still loaded. If the Add-in is not currently loaded when the application closes, the OnBeginShutdown event does not occur. When this event does occur, it occurs before the OnDisconnection event.

You can use the OnBeginShutdown event procedure to run code when the user closes an application. For example, you can run code that saves form data to a file.

It is possible that OnBeginShutdown can occur more than once. If an event handler cancels the environment shutdown, the next time the environment begins to shut down, OnBeginShutdown will occur again.


Note that this code works only in an Add-In project, not in macros.

Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices
Imports EnvDTE

<GuidAttribute("B25D9733-A1B2-420D-8F6B-478E2B051C83"), ProgIdAttribute("MyAddin1.Connect")> _
Public Class Connect
   Implements Extensibility.IDTExtensibility2

   Dim applicationObject As EnvDTE.DTE
   Dim addInInstance as EnvDTE.AddIn
   Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
      Msgbox("Shutdown event occuring.")
   End Sub
End Class

See Also

OnAddInsUpdate Method | OnConnection Method | OnDisconnection Method | OnStartupComplete Method

Applies To: IDTExtensibility2 Interface

© 2016 Microsoft