StackTrace 생성자

정의

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

오버로드

Name Description
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
Source:
StackTrace.cs
Source:
StackTrace.cs

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

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

예제

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

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
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 한 생성자 메서드를 보여 줍니다.

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
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
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 = 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
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

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

예외

매개 변수 e 는 .입니다 null.

설명

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

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

추가 정보

적용 대상

StackTrace(Int32)

Source:
StackTrace.cs
Source:
StackTrace.cs
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 호출자의 현재 스레드를 사용하여 만들어지고 파일 이름, 줄 번호 또는 열 정보가 포함되지 않습니다.

건너뛸 프레임 수가 인스턴스를 만들 StackTrace 때 호출 스택의 총 프레임 수보다 크거나 같으면 프레임이 포함되지 않습니다.

적용 대상

StackTrace(Exception, Int32)

Source:
StackTrace.cs
Source:
StackTrace.cs
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

추적을 시작할 스택의 프레임 수입니다.

예외

매개 변수 e 는 .입니다 null.

매개 변수가 skipFrames 음수입니다.

설명

StackTrace 파일 이름, 줄 번호 또는 열 정보가 없습니다.

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

건너뛸 프레임 수가 인스턴스를 만들 StackTrace 때 호출 스택의 총 프레임 수보다 크거나 같으면 프레임이 포함되지 않습니다.

추가 정보

적용 대상

StackTrace(Int32, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
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 한 생성자 메서드를 보여 줍니다.

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(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 가 일시 중단되지 않습니다.

설명

Important

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

추가 정보

적용 대상

StackTrace(Exception, Int32, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
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

예외

매개 변수 e 는 .입니다 null.

매개 변수가 skipFrames 음수입니다.

설명

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

건너뛸 프레임 수가 인스턴스를 만들 StackTrace 때 호출 스택의 총 프레임 수보다 크거나 같으면 프레임이 포함되지 않습니다.

추가 정보

적용 대상

StackTrace(Exception, Boolean)

Source:
StackTrace.cs
Source:
StackTrace.cs
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

예외

매개 변수 e 는 .입니다 null.

설명

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

추가 정보

적용 대상