StackTrace.GetFrames 메서드

정의

현재 스택 추적에 있는 모든 스택 프레임의 복사본을 반환합니다.

public:
 cli::array <System::Diagnostics::StackFrame ^> ^ GetFrames();
public:
 virtual cli::array <System::Diagnostics::StackFrame ^> ^ GetFrames();
public System.Diagnostics.StackFrame[] GetFrames ();
public virtual System.Diagnostics.StackFrame[] GetFrames ();
public virtual System.Diagnostics.StackFrame?[] GetFrames ();
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Diagnostics.StackFrame[] GetFrames ();
member this.GetFrames : unit -> System.Diagnostics.StackFrame[]
abstract member GetFrames : unit -> System.Diagnostics.StackFrame[]
override this.GetFrames : unit -> System.Diagnostics.StackFrame[]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member GetFrames : unit -> System.Diagnostics.StackFrame[]
override this.GetFrames : unit -> System.Diagnostics.StackFrame[]
Public Function GetFrames () As StackFrame()
Public Overridable Function GetFrames () As StackFrame()

반환

스택 추적의 함수 호출을 나타내는 StackFrame 형식의 배열입니다.

특성

예제

다음 코드 예제에서는 의 프레임을 열거하는 방법을 StackTrace보여 줍니다.

StackTrace^ st = gcnew StackTrace( 1,true );
array<StackFrame^>^stFrames = st->GetFrames();
for ( int i; i < stFrames->Length; i++ )
{
   StackFrame^ sf = stFrames[ i ];
   Console::WriteLine( "Method: {0}", sf->GetMethod() );

}
StackTrace st = new StackTrace(1, true);
StackFrame [] stFrames = st.GetFrames();

foreach(StackFrame sf in stFrames )
{
   Console.WriteLine("Method: {0}", sf.GetMethod() );
}
Dim strace As New StackTrace(1, True)
Dim stFrames As StackFrame() = strace.GetFrames()

Dim sf As StackFrame
For Each sf In  stFrames
   Console.WriteLine("Method: {0}", sf.GetMethod())
Next sf

설명

반환 StackFrame 된 배열을 사용하여 에서 함수 호출을 열거하고 검사합니다 StackTrace. 반환된 배열의 길이는 속성 값과 FrameCount 같습니다.

StackFrame 배열 요소는 역순으로 표시됩니다. 배열 인덱스 0의 는 StackFrame 스택 추적에서 가장 최근의 함수 호출과 호출 스택에 푸시된 마지막 프레임을 나타냅니다. 배열 인덱 FrameCount 스에서 1을 뺀 값은 StackFrame 스택 추적에서 가장 오래된 함수 호출과 호출 스택에 푸시된 첫 번째 프레임을 나타냅니다.

메서드를 사용하여 스택 추적의 GetFrames 모든 스택 프레임을 가져옵니다. 메서드를 GetFrame 사용하여 스택 추적에서 특정 스택 프레임을 가져옵니다. 인 StackFrame 덱스는 두 메서드에 의해 순서가 모두 지정됩니다. 예를 들어 에서 반환 GetFrames 된 배열의 StackFrame 인덱스 0은 입력 인덱스가 0인 에서 반환된 GetFrame 와 동일합니다StackFrame.

적용 대상

추가 정보