StackTrace 생성자

정의

StackTrace 클래스의 새 인스턴스를 초기화합니다.

오버로드

StackTrace()

호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Boolean)

필요에 따라 소스 정보를 캡처하고 호출 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(IEnumerable<StackFrame>)

개체 집합 StackFrame 에서 스택 추적을 생성합니다.

StackTrace(StackFrame)

단일 프레임을 포함하는 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Exception)

제공된 예외 개체를 사용하여 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Int32)

지정된 수의 프레임을 건너뛰어 호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Exception, Int32)

제공된 예외 개체를 사용하고 지정된 수의 프레임을 건너뛰어 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Int32, Boolean)

지정된 수의 프레임을 건너뛰고 필요에 따라 소스 정보를 캡처하여 호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Thread, Boolean)
사용되지 않음.

필요에 따라 소스 정보를 캡처하고 특정 스레드에 대해 StackTrace 클래스의 새 인스턴스를 초기화합니다.

이 생성자 오버로드를 사용하지 마십시오.

StackTrace(Exception, Int32, Boolean)

지정된 수의 프레임을 건너뛰고 필요에 따라 소스 정보를 캡처하여 제공된 예외 개체로 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace(Exception, Boolean)

필요에 따라 소스 정보를 캡처하고 제공된 예외 개체를 사용하여 StackTrace 클래스의 새 인스턴스를 초기화합니다.

StackTrace()

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace();
public StackTrace ();
Public Sub New ()

예제

다음 코드 예제에서는 스택 추적의 첫 번째 및 마지막 함수 호출을 표시합니다.

void Level5Method()
{
   try
   {
      ClassLevel6^ nestedClass = gcnew ClassLevel6;
      nestedClass->Level6Method();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( " Level5Method exception handler" );
      StackTrace^ st = gcnew StackTrace;
      
      // Display the most recent function call.
      StackFrame^ sf = st->GetFrame( 0 );
      Console::WriteLine();
      Console::WriteLine( "  Exception in method: " );
      Console::WriteLine( "      {0}", sf->GetMethod() );
      if ( st->FrameCount > 1 )
      {
         
         // Display the highest-level function call
         // in the trace.
         sf = st->GetFrame( st->FrameCount - 1 );
         Console::WriteLine( "  Original function call at top of call stack):" );
         Console::WriteLine( "      {0}", sf->GetMethod() );
      }
      Console::WriteLine();
      Console::WriteLine( "   ... throwing exception to next level ..." );
      Console::WriteLine( "-------------------------------------------------\n" );
      throw e;
   }

}
public void Level5Method()
{
   try
   {
      ClassLevel6 nestedClass = new ClassLevel6();
      nestedClass.Level6Method();
   }
   catch (Exception e)
   {
      Console.WriteLine(" Level5Method exception handler");

      StackTrace st = new StackTrace();

      // Display the most recent function call.
      StackFrame sf = st.GetFrame(0);
      Console.WriteLine();
      Console.WriteLine("  Exception in method: ");
      Console.WriteLine("      {0}", sf.GetMethod());

      if (st.FrameCount >1)
      {
         // Display the highest-level function call
         // in the trace.
         sf = st.GetFrame(st.FrameCount-1);
         Console.WriteLine("  Original function call at top of call stack):");
         Console.WriteLine("      {0}", sf.GetMethod());
      }

      Console.WriteLine();
      Console.WriteLine("   ... throwing exception to next level ...");
      Console.WriteLine("-------------------------------------------------\n");
      throw e;
   }
}
Public Sub Level5Method()
   Try
      Dim nestedClass As New ClassLevel6()
      nestedClass.Level6Method()
   Catch e As Exception
      Console.WriteLine(" Level5Method exception handler")
      
      Dim st As New StackTrace()
      
      ' Display the most recent function call.
      Dim sf As StackFrame = st.GetFrame(0)
      Console.WriteLine()
      Console.WriteLine("  Exception in method: ")
      Console.WriteLine("      {0}", sf.GetMethod())
      
      If st.FrameCount > 1 Then
         ' Display the highest-level function call in the trace.
         sf = st.GetFrame((st.FrameCount - 1))
         Console.WriteLine("  Original function call at top of call stack):")
         Console.WriteLine("      {0}", sf.GetMethod())
      End If
      
      Console.WriteLine()
      Console.WriteLine("   ... throwing exception to next level ...")
      Console.WriteLine("-------------------------------------------------")
      Console.WriteLine()
      Throw e
   End Try
End Sub

설명

StackTrace 호출자의 현재 스레드를 사용하여 생성되며 파일 이름, 줄 번호 또는 열 정보를 포함하지 않습니다.

호출 스택에 대한 요약 메서드 정보만 있는 완전한 추적을 원하는 경우 이 매개 변수가 없는 생성자를 사용합니다.

적용 대상

StackTrace(Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

필요에 따라 소스 정보를 캡처하고 호출 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(bool fNeedFileInfo);
public StackTrace (bool fNeedFileInfo);
new System.Diagnostics.StackTrace : bool -> System.Diagnostics.StackTrace
Public Sub New (fNeedFileInfo As Boolean)

매개 변수

fNeedFileInfo
Boolean

파일 이름, 줄 번호 및 열 번호를 캡처하려면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 다양 StackTrace 한 생성자 메서드를 보여 줍니다.

void Level2Method()
{
   try
   {
      ClassLevel3^ nestedClass = gcnew ClassLevel3;
      nestedClass->Level3Method();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( " Level2Method exception handler" );
      
      // Display the full call stack at this level.
      StackTrace^ st1 = gcnew StackTrace( true );
      Console::WriteLine( " Stack trace for this level: {0}", st1->ToString() );
      
      // Build a stack trace from one frame, skipping the
      // current frame and using the next frame.
      StackTrace^ st2 = gcnew StackTrace( gcnew StackFrame( 1,true ) );
      Console::WriteLine( " Stack trace built with next level frame: {0}", st2->ToString() );
      
      // Build a stack trace skipping the current frame, and
      // including all the other frames.
      StackTrace^ st3 = gcnew StackTrace( 1,true );
      Console::WriteLine( " Stack trace built from the next level up: {0}", st3->ToString() );
      Console::WriteLine();
      Console::WriteLine( "   ... throwing exception to next level ..." );
      Console::WriteLine( "-------------------------------------------------\n" );
      throw e;
   }

}
public void Level2Method()
{
   try
   {
      ClassLevel3 nestedClass = new ClassLevel3();
      nestedClass.Level3Method();
   }
   catch (Exception e)
   {
      Console.WriteLine(" Level2Method exception handler");

      // Display the full call stack at this level.
      StackTrace st1 = new StackTrace(true);
      Console.WriteLine(" Stack trace for this level: {0}",
         st1.ToString());

      // Build a stack trace from one frame, skipping the current
      // frame and using the next frame.
      StackTrace st2 = new StackTrace(new StackFrame(1, true));
      Console.WriteLine(" Stack trace built with next level frame: {0}",
         st2.ToString());

      // Build a stack trace skipping the current frame, and
      // including all the other frames.
      StackTrace st3 = new StackTrace(1, true);
      Console.WriteLine(" Stack trace built from the next level up: {0}",
         st3.ToString());

      Console.WriteLine();
      Console.WriteLine("   ... throwing exception to next level ...");
      Console.WriteLine("-------------------------------------------------\n");
      throw e;
   }
}
Public Sub Level2Method()
   Try
      Dim nestedClass As New ClassLevel3
      nestedClass.Level3Method()
   
   Catch e As Exception
      Console.WriteLine(" Level2Method exception handler")
      
      ' Display the full call stack at this level.
      Dim st1 As New StackTrace(True)
      Console.WriteLine(" Stack trace for this level: {0}", _
         st1.ToString())
      
      ' Build a stack trace from one frame, skipping the current
      ' frame and using the next frame.
      Dim st2 As New StackTrace(New StackFrame(1, True))
      Console.WriteLine(" Stack trace built with next level frame: {0}", _
          st2.ToString())
      
      ' Build a stack trace skipping the current frame, and
      ' including all the other frames.
      Dim st3 As New StackTrace(1, True)
      Console.WriteLine(" Stack trace built from the next level up: {0}", _
          st3.ToString())
      
      Console.WriteLine()
      Console.WriteLine("   ... throwing exception to next level ...")
      Console.WriteLine("-------------------------------------------------")
      Console.WriteLine()
      Throw e
   End Try
End Sub

설명

StackTrace 호출자의 현재 스레드를 사용하여 만들어집니다.

적용 대상

StackTrace(IEnumerable<StackFrame>)

Source:
StackTrace.cs
Source:
StackTrace.cs

개체 집합 StackFrame 에서 스택 추적을 생성합니다.

public:
 StackTrace(System::Collections::Generic::IEnumerable<System::Diagnostics::StackFrame ^> ^ frames);
public StackTrace (System.Collections.Generic.IEnumerable<System.Diagnostics.StackFrame> frames);
new System.Diagnostics.StackTrace : seq<System.Diagnostics.StackFrame> -> System.Diagnostics.StackTrace
Public Sub New (frames As IEnumerable(Of StackFrame))

매개 변수

frames
IEnumerable<StackFrame>

스택 추적에 있어야 하는 스택 프레임 집합입니다.

적용 대상

StackTrace(StackFrame)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

단일 프레임을 포함하는 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(System::Diagnostics::StackFrame ^ frame);
public StackTrace (System.Diagnostics.StackFrame frame);
new System.Diagnostics.StackTrace : System.Diagnostics.StackFrame -> System.Diagnostics.StackTrace
Public Sub New (frame As StackFrame)

매개 변수

frame
StackFrame

StackTrace 개체가 포함해야 하는 프레임입니다.

예제

다음 코드 예제에서는 스택 추적 정보를 이벤트 로그 항목에 씁니다.

StackFrame^ fr = gcnew StackFrame( 1,true );
StackTrace^ st = gcnew StackTrace( fr );
EventLog::WriteEntry( fr->GetMethod()->Name, st->ToString(), EventLogEntryType::Warning );
StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
                    st.ToString(),
                    EventLogEntryType.Warning);
Dim frame As New StackFrame(1, True)
Dim strace As New StackTrace(frame)            

EventLog.WriteEntry(frame.GetMethod().Name, _
                    strace.ToString(), _
                    EventLogEntryType.Warning)

설명

전체 스택 추적의 오버헤드를 원하지 않는 경우 이 생성자를 사용합니다.

추가 정보

적용 대상

StackTrace(Exception)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

제공된 예외 개체를 사용하여 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(Exception ^ e);
public StackTrace (Exception e);
new System.Diagnostics.StackTrace : Exception -> System.Diagnostics.StackTrace
Public Sub New (e As Exception)

매개 변수

e
Exception

스택 추적을 생성할 원본 예외 개체입니다.

예외

매개 변수 enull인 경우

설명

StackTrace 호출자의 현재 스레드를 사용하여 생성되며 파일 이름, 줄 번호 또는 열 정보를 포함하지 않습니다.

결과 스택 추적은 예외 발생 시 스택을 설명합니다.

추가 정보

적용 대상

StackTrace(Int32)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

지정된 수의 프레임을 건너뛰어 호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(int skipFrames);
public StackTrace (int skipFrames);
new System.Diagnostics.StackTrace : int -> System.Diagnostics.StackTrace
Public Sub New (skipFrames As Integer)

매개 변수

skipFrames
Int32

추적할 스택 프레임의 개수입니다.

예외

skipFrames 매개 변수가 음수인 경우

설명

StackTrace 호출자의 현재 스레드를 사용하여 생성되며 파일 이름, 줄 번호 또는 열 정보를 포함하지 않습니다.

건너뛸 프레임 수가 instance 생성 StackTrace 될 때 호출 스택의 총 프레임 수보다 크거나 같으면 에 프레임이 포함되지 않습니다.

적용 대상

StackTrace(Exception, Int32)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

제공된 예외 개체를 사용하고 지정된 수의 프레임을 건너뛰어 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(Exception ^ e, int skipFrames);
public StackTrace (Exception e, int skipFrames);
new System.Diagnostics.StackTrace : Exception * int -> System.Diagnostics.StackTrace
Public Sub New (e As Exception, skipFrames As Integer)

매개 변수

e
Exception

스택 추적을 생성할 원본 예외 개체입니다.

skipFrames
Int32

추적할 스택 프레임의 개수입니다.

예외

매개 변수 enull인 경우

skipFrames 매개 변수가 음수인 경우

설명

StackTrace 파일 이름, 줄 번호 또는 열 정보를 포함하지 않습니다.

결과 스택 추적은 예외 발생 시 스택을 설명합니다.

건너뛸 프레임 수가 instance 생성 StackTrace 될 때 호출 스택의 총 프레임 수보다 크거나 같으면 에 프레임이 포함되지 않습니다.

추가 정보

적용 대상

StackTrace(Int32, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

지정된 수의 프레임을 건너뛰고 필요에 따라 소스 정보를 캡처하여 호출자 프레임에서 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(int skipFrames, bool fNeedFileInfo);
public StackTrace (int skipFrames, bool fNeedFileInfo);
new System.Diagnostics.StackTrace : int * bool -> System.Diagnostics.StackTrace
Public Sub New (skipFrames As Integer, fNeedFileInfo As Boolean)

매개 변수

skipFrames
Int32

추적할 스택 프레임의 개수입니다.

fNeedFileInfo
Boolean

파일 이름, 줄 번호 및 열 번호를 캡처하려면 true이고, 그렇지 않으면 false입니다.

예외

skipFrames 매개 변수가 음수인 경우

예제

다음 코드 예제에서는 다양 StackTrace 한 생성자 메서드를 보여 줍니다.

void Level2Method()
{
   try
   {
      ClassLevel3^ nestedClass = gcnew ClassLevel3;
      nestedClass->Level3Method();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( " Level2Method exception handler" );
      
      // Display the full call stack at this level.
      StackTrace^ st1 = gcnew StackTrace( true );
      Console::WriteLine( " Stack trace for this level: {0}", st1->ToString() );
      
      // Build a stack trace from one frame, skipping the
      // current frame and using the next frame.
      StackTrace^ st2 = gcnew StackTrace( gcnew StackFrame( 1,true ) );
      Console::WriteLine( " Stack trace built with next level frame: {0}", st2->ToString() );
      
      // Build a stack trace skipping the current frame, and
      // including all the other frames.
      StackTrace^ st3 = gcnew StackTrace( 1,true );
      Console::WriteLine( " Stack trace built from the next level up: {0}", st3->ToString() );
      Console::WriteLine();
      Console::WriteLine( "   ... throwing exception to next level ..." );
      Console::WriteLine( "-------------------------------------------------\n" );
      throw e;
   }

}
public void Level2Method()
{
   try
   {
      ClassLevel3 nestedClass = new ClassLevel3();
      nestedClass.Level3Method();
   }
   catch (Exception e)
   {
      Console.WriteLine(" Level2Method exception handler");

      // Display the full call stack at this level.
      StackTrace st1 = new StackTrace(true);
      Console.WriteLine(" Stack trace for this level: {0}",
         st1.ToString());

      // Build a stack trace from one frame, skipping the current
      // frame and using the next frame.
      StackTrace st2 = new StackTrace(new StackFrame(1, true));
      Console.WriteLine(" Stack trace built with next level frame: {0}",
         st2.ToString());

      // Build a stack trace skipping the current frame, and
      // including all the other frames.
      StackTrace st3 = new StackTrace(1, true);
      Console.WriteLine(" Stack trace built from the next level up: {0}",
         st3.ToString());

      Console.WriteLine();
      Console.WriteLine("   ... throwing exception to next level ...");
      Console.WriteLine("-------------------------------------------------\n");
      throw e;
   }
}
Public Sub Level2Method()
   Try
      Dim nestedClass As New ClassLevel3
      nestedClass.Level3Method()
   
   Catch e As Exception
      Console.WriteLine(" Level2Method exception handler")
      
      ' Display the full call stack at this level.
      Dim st1 As New StackTrace(True)
      Console.WriteLine(" Stack trace for this level: {0}", _
         st1.ToString())
      
      ' Build a stack trace from one frame, skipping the current
      ' frame and using the next frame.
      Dim st2 As New StackTrace(New StackFrame(1, True))
      Console.WriteLine(" Stack trace built with next level frame: {0}", _
          st2.ToString())
      
      ' Build a stack trace skipping the current frame, and
      ' including all the other frames.
      Dim st3 As New StackTrace(1, True)
      Console.WriteLine(" Stack trace built from the next level up: {0}", _
          st3.ToString())
      
      Console.WriteLine()
      Console.WriteLine("   ... throwing exception to next level ...")
      Console.WriteLine("-------------------------------------------------")
      Console.WriteLine()
      Throw e
   End Try
End Sub

설명

건너뛸 프레임 수가 instance 생성 StackTrace 될 때 호출 스택의 총 프레임 수보다 크거나 같으면 에 프레임이 포함되지 않습니다.

적용 대상

StackTrace(Thread, Boolean)

주의

This constructor has been deprecated. Please use a constructor that does not require a Thread parameter. http://go.microsoft.com/fwlink/?linkid=14202

필요에 따라 소스 정보를 캡처하고 특정 스레드에 대해 StackTrace 클래스의 새 인스턴스를 초기화합니다.

이 생성자 오버로드를 사용하지 마십시오.

public:
 StackTrace(System::Threading::Thread ^ targetThread, bool needFileInfo);
public StackTrace (System.Threading.Thread targetThread, bool needFileInfo);
[System.Obsolete("This constructor has been deprecated.  Please use a constructor that does not require a Thread parameter.  http://go.microsoft.com/fwlink/?linkid=14202")]
public StackTrace (System.Threading.Thread targetThread, bool needFileInfo);
new System.Diagnostics.StackTrace : System.Threading.Thread * bool -> System.Diagnostics.StackTrace
[<System.Obsolete("This constructor has been deprecated.  Please use a constructor that does not require a Thread parameter.  http://go.microsoft.com/fwlink/?linkid=14202")>]
new System.Diagnostics.StackTrace : System.Threading.Thread * bool -> System.Diagnostics.StackTrace
Public Sub New (targetThread As Thread, needFileInfo As Boolean)

매개 변수

targetThread
Thread

스택 추적이 필요한 스레드입니다.

needFileInfo
Boolean

파일 이름, 줄 번호 및 열 번호를 캡처하려면 true이고, 그렇지 않으면 false입니다.

특성

예외

targetThread 스레드가 일시 중단되지 않는 경우

설명

중요

이 생성자를 사용하지 마세요. 사용되지 않으며 권장되는 대안은 없습니다. 스레드를 일시 중단하면 실행 중인 코드를 알 수 없으며 교착 상태가 매우 쉽게 발생할 수 있습니다. 예를 들어 보안 권한 평가 중에 잠금을 보유하는 동안 스레드를 일시 중단하면 의 AppDomain 다른 스레드가 차단될 수 있습니다. 클래스 생성자를 실행하는 동안 스레드를 일시 중단하면 해당 클래스를 사용하려는 의 AppDomain 다른 스레드가 차단됩니다.

추가 정보

적용 대상

StackTrace(Exception, Int32, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

지정된 수의 프레임을 건너뛰고 필요에 따라 소스 정보를 캡처하여 제공된 예외 개체로 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(Exception ^ e, int skipFrames, bool fNeedFileInfo);
public StackTrace (Exception e, int skipFrames, bool fNeedFileInfo);
new System.Diagnostics.StackTrace : Exception * int * bool -> System.Diagnostics.StackTrace
Public Sub New (e As Exception, skipFrames As Integer, fNeedFileInfo As Boolean)

매개 변수

e
Exception

스택 추적을 생성할 원본 예외 개체입니다.

skipFrames
Int32

추적할 스택 프레임의 개수입니다.

fNeedFileInfo
Boolean

파일 이름, 줄 번호 및 열 번호를 캡처하려면 true이고, 그렇지 않으면 false입니다.

예외

매개 변수 enull인 경우

skipFrames 매개 변수가 음수인 경우

설명

결과 스택 추적은 예외 발생 시 스택을 설명합니다.

건너뛸 프레임 수가 instance 생성 StackTrace 될 때 호출 스택의 총 프레임 수보다 크거나 같으면 에 프레임이 포함되지 않습니다.

추가 정보

적용 대상

StackTrace(Exception, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
Source:
StackTrace.cs

필요에 따라 소스 정보를 캡처하고 제공된 예외 개체를 사용하여 StackTrace 클래스의 새 인스턴스를 초기화합니다.

public:
 StackTrace(Exception ^ exception, bool needFileInfo);
public:
 StackTrace(Exception ^ e, bool fNeedFileInfo);
public StackTrace (Exception exception, bool needFileInfo);
public StackTrace (Exception e, bool fNeedFileInfo);
new System.Diagnostics.StackTrace : Exception * bool -> System.Diagnostics.StackTrace
new System.Diagnostics.StackTrace : Exception * bool -> System.Diagnostics.StackTrace
Public Sub New (exception As Exception, needFileInfo As Boolean)
Public Sub New (e As Exception, fNeedFileInfo As Boolean)

매개 변수

exceptione
Exception

스택 추적을 생성할 원본 예외 개체입니다.

needFileInfofNeedFileInfo
Boolean

파일 이름, 줄 번호 및 열 번호를 캡처하려면 true이고, 그렇지 않으면 false입니다.

예외

매개 변수 enull인 경우

설명

결과 스택 추적은 예외 발생 시 스택을 설명합니다.

추가 정보

적용 대상