Visual Studio : executing clean up code when debugging stops

You can use the DTE (VisualStudio Automation Model) to write a macro that will be invoked when a stop debug happens, below is a snippet of the idea.

Private Sub DebuggerEvents_OnEnterBreakMode(
   ByVal Reason As EnvDTE.dbgEventReason, 
   ByRef ExecutionAction As EnvDTE.dbgExecutionAction) Handles DebuggerEvents.OnEnterBreakMode
    If (Reason = dbgEventReason.dbgEventReasonStopDebugging) Then
        // DO YOUR CLEAN UP CODE HERE
    End If
End Sub

Leave a Comment