StackFrame.Collection 属性

获取包含某个对象的集合,该对象支持此属性或包含在此代码构造中。 对于不是从集合中获得的对象,返回 null。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

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

属性值

类型:EnvDTE.StackFrames
一个 StackFrames 集合。

示例

下面的示例演示如何使用 Collection 属性。

要测试此属性

  1. 在目标应用程序中,在 Main() 方法以外的方法内部设置一个断点。

  2. 以调试模式运行目标应用程序。

  3. 当应用程序停在该断点处时,运行外接程序。

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

.NET Framework 安全性

请参见

参考

StackFrame 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例