Condividi tramite


Proprietà StackFrame.Collection

Ottiene la raccolta contenente l'oggetto che supporta la proprietà o è contenuto nel costrutto di codice.Null viene restituito per un oggetto che non viene ottenuto da una raccolta.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

'Dichiarazione
ReadOnly Property Collection As StackFrames
StackFrames Collection { get; }
property StackFrames^ Collection {
    StackFrames^ get ();
}
abstract Collection : StackFrames
function get Collection () : StackFrames

Valore proprietà

Tipo: EnvDTE.StackFrames
In StackFrames raccolta.

Esempi

Nell'esempio seguente viene illustrato come utilizzare Collection proprietà.

Per verificare questa proprietà

  1. Nell'applicazione di destinazione, impostare un punto di interruzione nel metodo diverso dal metodo Main().

  2. Eseguire l'applicazione di destinazione in modalità di debug.

  3. Quando l'applicazione si interrompe sul punto di interruzione, eseguire il componente aggiuntivo.

public static void TestStackFrames(DTE dte)
{
    // Setup 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("Stack Frames Test");
    owp.Activate();

    EnvDTE.StackFrames stackFrames = dte.Debugger.CurrentThread.StackFrames;
    owp.OutputString("\nNumber of items in the Current Stack collection: " + 
                     stackFrames.Item(1).Collection.Count + "\n");

    foreach(EnvDTE.StackFrame sf in stackFrames)
    {
        owp.OutputString("\nStack Frame: " + sf.FunctionName);
        owp.OutputString("\n  Edition of the environment : " + sf.DTE.Edition);
        owp.OutputString("\n  Language                   : " + sf.Language);
        owp.OutputString("\n  Locals");
        EnvDTE.Expressions expressions = sf.Locals;
        foreach(EnvDTE.Expression exp in expressions)
            owp.OutputString("\n    " + exp.Name + " = " + exp.Value);
        owp.OutputString("\n  Module                     : " + sf.Module);
        owp.OutputString("\n  Current Thread ID          : " + sf.Parent.ID);
        owp.OutputString("\n  Return Type                : " + sf.ReturnType);
    }
}
Shared Sub TestStackFrames(ByRef dte As EnvDTE.DTE)
    Dim str As String
    Dim stackFrames As EnvDTE.StackFrames = dte.Debugger.CurrentThread.StackFrames
    str = "Number of items in the Current Stack collection: " + _
          stackFrames.Item(1).Collection.Count.ToString()
    For Each sf As EnvDTE.StackFrame In stackFrames
        str += vbCrLf + vbCrLf + "  Stack Frame: " + sf.FunctionName
        str += vbCrLf + "  Edition of the environment: " + sf.DTE.Edition
        str += vbCrLf + "  Language: " + sf.Language
        str += vbCrLf + "  Locals"
        Dim expressions As EnvDTE.Expressions = sf.Locals
        For Each exp As EnvDTE.Expression In expressions
            str += vbCrLf + "    " + exp.Name + " = " + exp.Value.ToString()
        Next
        str += vbCrLf + "  Module: " + sf.Module
        str += vbCrLf + "  Current Thread ID: " + sf.Parent.ID.ToString()
        str += vbCrLf + "  Return Type: " + sf.ReturnType
    Next
    MessageBox.Show(str, "Stack Frame Test - Properties")
End Sub

Sicurezza di .NET Framework

Vedere anche

Riferimenti

StackFrame Interfaccia

Spazio dei nomi EnvDTE

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione