Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Extensibility
Debugger3 Interface

Debugger3 is used to interrogate and manipulate the state of the debugger and the program being debugged. Debugger3 supersedes the Debugger2 and Debugger interfaces.

Namespace:  EnvDTE90
Assembly:  EnvDTE90 (in EnvDTE90.dll)
Visual Basic (Declaration)
<GuidAttribute("87DFC8DA-67B4-4954-BB89-6A277A50BAFC")> _
Public Interface Debugger3 _
    Implements Debugger2
Visual Basic (Usage)
Dim instance As Debugger3
C#
[GuidAttribute("87DFC8DA-67B4-4954-BB89-6A277A50BAFC")]
public interface Debugger3 : Debugger2
Visual C++
[GuidAttribute(L"87DFC8DA-67B4-4954-BB89-6A277A50BAFC")]
public interface class Debugger3 : Debugger2
JScript
public interface Debugger3 extends Debugger2

The debugger is available through the DTE2 object through its Debugger property, as shown in the following example. One debugger object is available for each instance of the interactive development environment (IDE).

Visual Basic
Imports System
Imports EnvDTE
Imports EnvDTE90
Imports EnvDTE90
Imports System.Diagnostics

Public Module Module1
    'This function returns true if the debugger is actively debugging.
    Function IsDebugging() As Boolean
        Dim debugger As EnvDTE90.Debugger3
        debugger = DTE.Debugger
        If (debugger Is Nothing) Then
            MsgBox("Debugger doesn't exist! Fatal error.")
            IsDebugging = false
        Else
            IsDebugging = (debugger.CurrentMode <> _
            dbgDebugMode.dbgDesignMode)
        End If
    End Function
End Module
Visual C++
// The following C++ program can be run from the command line.
// It detects whether an instance of Visual Studio is currently 
// running,and if so, prints a message stating whether its debugger
// is actively debugging.

#include <stdio.h>
#import "dte90.olb" raw_interfaces_only named_guids
using namespace EnvDTE90;
int main(void)
{
    int nRet = 0;
    CoInitialize(NULL);
    IUnknownPtr pUnk;
    GetActiveObject(CLSID_DTE, NULL, &pUnk);
    if (pUnk == NULL) {
        printf ("No instance of Visual Studio is running.\n");
    }
    else {
        _DTEPtr pDTE = pUnk;
        if (pDTE) {
            DebuggerPtr pDebugger;
            if (SUCCEEDED(pDTE->get_Debugger(&pDebugger3)) && 
            pDebugger3
            != NULL){
                dbgDebugMode mode;
                if (SUCCEEDED(pDebugger3->get_CurrentMode(&mode))) {
                    if (mode != dbgDesignMode) {
                        printf("Debugger is active.\n");
                        nRet = 1;
                    }
                    else {
                        printf("Debugger is not active.\n");
                    }
                }
            }
        }
    }
    CoUninitialize();
    return nRet;
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker