Debugger.ExecuteStatement Method

Executes the specified statement. If the TreatAsExpression flag is true, then the string is interpreted as an expression, and output is sent to the Command Window.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Sub ExecuteStatement ( _
    Statement As String, _
    Timeout As Integer, _
    TreatAsExpression As Boolean _
)
void ExecuteStatement(
    string Statement,
    int Timeout,
    bool TreatAsExpression
)
void ExecuteStatement(
    [InAttribute] String^ Statement, 
    [InAttribute] int Timeout, 
    [InAttribute] bool TreatAsExpression
)
abstract ExecuteStatement : 
        Statement:string * 
        Timeout:int * 
        TreatAsExpression:bool -> unit
function ExecuteStatement(
    Statement : String, 
    Timeout : int, 
    TreatAsExpression : boolean
)

Parameters

  • Timeout
    Type: System.Int32

    The timeout period, in milliseconds.

  • TreatAsExpression
    Type: System.Boolean

    The treat as expression. True if the string is to be interpreted as an expression; otherwise False.

Remarks

ExecuteStatement executes the specified statement. A statement differs from an expression in that a statement can consist of one or more expressions. Therefore, typically no value can be associated or returned by statement execution.

Some languages, such as Visual Basic, support a language syntax in which the context in which a statement appears indicates how the statement should be evaluated. For example, if your Visual Basic code has statement, a = 1, it is interpreted as an expression if the code appears inside an If...Then statement. For more information, see If...Then...Else Statement (Visual Basic). In that case, it is interpreted as a statement if it appears alone on a line. The expression tests a against the value of 1; the statement sets a equal to 2. See the Example below.

Output from this method is sent to the Command window.

Examples

The following example demonstrates how to use the ExecuteStatement method.

To test this method:

  1. Set the breakpoint in the target application after a value is assigned to the variable.

  2. Run the target application in the debug mode.

  3. When the application stops at the breakpoint, run the add-in.

  4. The value of the variable changes to a new value.

public static void ExecuteStatement(DTE dte)
{
    // Setup the debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("ExecuteStatement Method Test");
    owp.Activate();

    dte.Debugger.ExecuteStatement("tempC = 100.0", 100, false);
}
Shared Sub ExecuteStatementTest(ByRef dte As EnvDTE.DTE)
    dte.Debugger.ExecuteStatement("tempC = 100.0", 100, False)
End Sub

.NET Framework Security

See Also

Reference

Debugger Interface

EnvDTE Namespace