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 屬性。
若要測試這個屬性
在目標應用程式的方法內設定中斷點 (除了 Main() 方法以外)。
在偵錯模式執行目標應用程式。
當應用程式在中斷點停止時,請執行增益集。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。