StackFrame 클래스

정의

현재 스레드의 호출 스택에 대한 함수를 나타내는 StackFrame에 대한 정보를 제공합니다.

public ref class StackFrame sealed
public ref class StackFrame
public sealed class StackFrame
public class StackFrame
[System.Serializable]
public class StackFrame
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class StackFrame
type StackFrame = class
[<System.Serializable>]
type StackFrame = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type StackFrame = class
Public NotInheritable Class StackFrame
Public Class StackFrame
상속
StackFrame
특성

예제

다음 예제에서는 클래스를 사용하여 StackFrame 스택 추적에 대한 스택 프레임 정보를 제공하는 방법을 보여 줍니다.

using System;
using System.Diagnostics;

namespace StackFrameExample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Method1();
            }
            catch (Exception e)
            {
                StackTrace st = new StackTrace();
                StackTrace st1 = new StackTrace(new StackFrame(true));
                Console.WriteLine(" Stack trace for Main: {0}",
                   st1.ToString());
                Console.WriteLine(st.ToString());
            }
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
        private static void Method1()
        {
            try
            {
                Method2(4);
            }
            catch (Exception e)
            {
                StackTrace st = new StackTrace();
                StackTrace st1 = new StackTrace(new StackFrame(true));
                Console.WriteLine(" Stack trace for Method1: {0}",
                   st1.ToString());
                Console.WriteLine(st.ToString());
                // Build a stack trace for the next frame.
                StackTrace st2 = new StackTrace(new StackFrame(1, true));
                Console.WriteLine(" Stack trace for next level frame: {0}",
                   st2.ToString());
                throw e;
            }
        }
        private static void Method2( int count)
        {
            try
            {
                if (count < 5)
                    throw new ArgumentException("count too large", "count");
            }
            catch (Exception e)
            {
                StackTrace st = new StackTrace();
                StackTrace st1 = new StackTrace(new StackFrame(2,true));
                Console.WriteLine(" Stack trace for Method2: {0}",
                   st1.ToString());
                Console.WriteLine(st.ToString());
                throw e;
            }
        }
    }
}
Imports System.Diagnostics



Class Program

    Shared Sub Main(ByVal args() As String)
        Try
            Method1()
        Catch e As Exception
            Dim st As New StackTrace()
            Dim st1 As New StackTrace(New StackFrame(True))
            Console.WriteLine(" Stack trace for Main: {0}", st1.ToString())
            Console.WriteLine(st.ToString())
        End Try
        Console.WriteLine("Press Enter to exit.")
        Console.ReadLine()

    End Sub

    Private Shared Sub Method1()
        Try
            Method2(4)
        Catch e As Exception
            Dim st As New StackTrace()
            Dim st1 As New StackTrace(New StackFrame(True))
            Console.WriteLine(" Stack trace for Method1: {0}", st1.ToString())
            Console.WriteLine(st.ToString())
            ' Build a stack trace for the next frame.
            Dim st2 As New StackTrace(New StackFrame(1, True))
            Console.WriteLine(" Stack trace for next level frame: {0}", st2.ToString())
            Throw e
        End Try

    End Sub

    Private Shared Sub Method2(ByVal count As Integer)
        Try
            If count < 5 Then
                Throw New ArgumentException("count too large", "count")
            End If
        Catch e As Exception
            Dim st As New StackTrace()
            Dim st1 As New StackTrace(New StackFrame(2, True))
            Console.WriteLine(" Stack trace for Method2: {0}", st1.ToString())
            Console.WriteLine(st.ToString())
            Throw e
        End Try

    End Sub
End Class

다음 예제에서는 클래스의 멤버를 사용하는 방법을 보여 줍니다 StackFrame .

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

// This console application illustrates various uses
// of the StackTrace and StackFrame classes.
namespace SampleInternal
{
   public ref class ClassLevel6
   {
   public:
      void Level6Method()
      {
         throw gcnew Exception( "An error occurred in the lowest internal class method." );
      }

   };

   public ref class ClassLevel5
   {
   public:

      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 ref class ClassLevel4
   {
   public:
      void Level4Method()
      {
         
         try
         {
            ClassLevel5^ nestedClass = gcnew ClassLevel5;
            nestedClass->Level5Method();
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( " Level4Method exception handler" );
            
            // Build a stack trace from a dummy stack frame.
            // Explicitly specify the source file name, line number
            // and column number.
            StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",79,24 ) );
            Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() );
            
            // Access the StackFrames explicitly to display the file
            // name, line number and column number properties.
            // StackTrace.ToString only includes the method name. 
            for ( int i = 0; i < st->FrameCount; i++ )
            {
               StackFrame^ sf = st->GetFrame( i );
               Console::WriteLine( " File: {0}", sf->GetFileName() );
               Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
               Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );

            }
            Console::WriteLine();
            Console::WriteLine( "   ... throwing exception to next level ..." );
            Console::WriteLine( "-------------------------------------------------\n" );
            throw e;
         }

         
      }

   };

   public ref class ClassLevel3
   {
   public:

      void Level3Method()
      {
         try
         {
            ClassLevel4^ nestedClass = gcnew ClassLevel4;
            nestedClass->Level4Method();
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( " Level3Method exception handler" );
            
            // Build a stack trace from a dummy stack frame.
            // Explicitly specify the source file name and line number.
            StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",60 ) );
            Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() );
            for ( int i = 0; i < st->FrameCount; i++ )
            {
               
               // Display the stack frame properties.
               StackFrame^ sf = st->GetFrame( i );
               Console::WriteLine( " File: {0}", sf->GetFileName() );
               Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
               
               // Note that the column number defaults to zero
               // when not initialized.
               Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
               Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() );
               Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() );
               

            }
            Console::WriteLine();
            Console::WriteLine( "   ... throwing exception to next level ..." );
            Console::WriteLine( "-------------------------------------------------\n" );
            throw e;
         }

      }

   };

   public ref class ClassLevel2
   {
   public:

      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 ref class ClassLevel1
   {
   public:

      void InternalMethod()
      {
         try
         {
            ClassLevel2^ nestedClass = gcnew ClassLevel2;
            nestedClass->Level2Method();
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( " InternalMethod exception handler" );
            
            // Build a stack trace from one frame, skipping the
            // current frame and using the next frame.  By
            // default, file and line information are not displayed.
            StackTrace^ st = gcnew StackTrace( gcnew StackFrame( 1 ) );
            Console::WriteLine( " Stack trace for next level frame: {0}", st->ToString() );
            Console::WriteLine( " Stack frame for next level: " );
            Console::WriteLine( "   {0}", st->GetFrame( 0 )->ToString() );
            Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() );
            Console::WriteLine();
            Console::WriteLine( "   ... throwing exception to next level ..." );
            Console::WriteLine( "-------------------------------------------------\n" );
            throw e;
         }

      }

   };

}


using namespace SampleInternal;

namespace SamplePublic
{
   class ConsoleApp
   {
   public:


      [STAThread]
      static void Main()
      {
         ClassLevel1 ^ mainClass = gcnew ClassLevel1;
         try
         {
            mainClass->InternalMethod();
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( " Main method exception handler" );
            
            // Display file and line information, if available.
            StackTrace^ st = gcnew StackTrace( gcnew StackFrame( true ) );
            Console::WriteLine( " Stack trace for current level: {0}", st->ToString() );
            Console::WriteLine( " File: {0}", st->GetFrame( 0 )->GetFileName() );
            Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() );
            Console::WriteLine();
            Console::WriteLine( "-------------------------------------------------\n" );
         }

      }

   };

}

int main()
{
   SamplePublic::ConsoleApp::Main();
}

using System;
using System.Diagnostics;

using SampleInternal;

namespace SamplePublic
{
    // This console application illustrates various uses
    // of the StackTrace and StackFrame classes.
    class ConsoleApp
    {
       [STAThread]
       static void Main()
        {
            ClassLevel1 mainClass = new ClassLevel1();

            try {
                mainClass.InternalMethod();
            }
            catch (Exception) {
               Console.WriteLine(" Main method exception handler");

               // Display file and line information, if available.
               StackTrace st = new StackTrace(new StackFrame(true));
               Console.WriteLine(" Stack trace for current level: {0}",
                   st.ToString());
               Console.WriteLine(" File: {0}",
                  st.GetFrame(0).GetFileName());
               Console.WriteLine(" Line Number: {0}",
                   st.GetFrame(0).GetFileLineNumber().ToString());

               Console.WriteLine();
               Console.WriteLine("-------------------------------------------------\n");
            }
        }
    }
}

namespace SampleInternal
{
   public class ClassLevel1
   {
      public void InternalMethod()
      {
         try
         {
            ClassLevel2 nestedClass = new ClassLevel2();
            nestedClass.Level2Method();
         }
         catch (Exception e)
         {
            Console.WriteLine(" InternalMethod exception handler");

            // Build a stack trace from one frame, skipping the
            // current frame and using the next frame.  By
            // default, file and line information are not displayed.
            StackTrace st = new StackTrace(new StackFrame(1));
            Console.WriteLine(" Stack trace for next level frame: {0}",
               st.ToString());
            Console.WriteLine(" Stack frame for next level: ");
            Console.WriteLine("   {0}", st.GetFrame(0).ToString());

            Console.WriteLine(" Line Number: {0}",
               st.GetFrame(0).GetFileLineNumber().ToString());

            Console.WriteLine();
            Console.WriteLine("   ... throwing exception to next level ...");
            Console.WriteLine("-------------------------------------------------\n");
            throw e;
         }
      }
   }

   public class ClassLevel2
   {
      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 class ClassLevel3
   {
      public void Level3Method()
      {
         try
         {
            ClassLevel4 nestedClass = new ClassLevel4();
            nestedClass.Level4Method();
         }
         catch (Exception e)
         {
            Console.WriteLine(" Level3Method exception handler");

            // Build a stack trace from a dummy stack frame.
            // Explicitly specify the source file name and
            // line number.
            StackTrace st = new StackTrace(new StackFrame("source.cs", 60));
            Console.WriteLine(" Stack trace with dummy stack frame: {0}",
                        st.ToString());
            for(int i =0; i< st.FrameCount; i++ )
            {
               // Display the stack frame properties.
               StackFrame sf = st.GetFrame(i);
               Console.WriteLine(" File: {0}", sf.GetFileName());
               Console.WriteLine(" Line Number: {0}",
                  sf.GetFileLineNumber());
               // Note that the column number defaults to zero
               // when not initialized.
               Console.WriteLine(" Column Number: {0}",
                  sf.GetFileColumnNumber());
               if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
               {
                  Console.WriteLine(" Intermediate Language Offset: {0}",
                     sf.GetILOffset());
               }
               if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN)
               {
                  Console.WriteLine(" Native Offset: {0}",
                     sf.GetNativeOffset());
               }
            }
            Console.WriteLine();
            Console.WriteLine("   ... throwing exception to next level ...");
            Console.WriteLine("-------------------------------------------------\n");
            throw e;
         }
      }
   }

   public class ClassLevel4
   {
      public void Level4Method()
      {
         try
         {
            ClassLevel5 nestedClass = new ClassLevel5();
            nestedClass.Level5Method();
         }
         catch (Exception e)
         {
            Console.WriteLine(" Level4Method exception handler");

            // Build a stack trace from a dummy stack frame.
            // Explicitly specify the source file name, line number
            // and column number.
            StackTrace st = new StackTrace(new StackFrame("source.cs", 79, 24));
            Console.WriteLine(" Stack trace with dummy stack frame: {0}",
                           st.ToString());

            // Access the StackFrames explicitly to display the file
            // name, line number and column number properties.
            // StackTrace.ToString only includes the method name.
            for(int i =0; i< st.FrameCount; i++ )
            {
               StackFrame sf = st.GetFrame(i);
               Console.WriteLine(" File: {0}", sf.GetFileName());
               Console.WriteLine(" Line Number: {0}",
                  sf.GetFileLineNumber());
               Console.WriteLine(" Column Number: {0}",
                  sf.GetFileColumnNumber());
            }
            Console.WriteLine();
            Console.WriteLine("   ... throwing exception to next level ...");
            Console.WriteLine("-------------------------------------------------\n");
            throw e;
         }
      }
   }

   public class ClassLevel5
   {
      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 class ClassLevel6
   {
      public void Level6Method()
      {
         throw new Exception("An error occurred in the lowest internal class method.");
      }
   }
}
Imports System.Diagnostics

Imports SampleInternal

Namespace SamplePublic
   
   ' This console application illustrates various uses
   ' of the StackTrace and StackFrame classes.
   
   Class ConsoleApp
      
      <STAThread()>  _
      Shared Sub Main()
         Dim mainClass As New ClassLevel1
         
         Try
            mainClass.InternalMethod()
         Catch
            Console.WriteLine(" Main method exception handler")
            
            ' Display file and line information, if available.
            Dim st As New StackTrace(New StackFrame(True))
            Console.WriteLine(" Stack trace for current level: {0}", _
               st.ToString())
            Console.WriteLine(" File: {0}", _
               st.GetFrame(0).GetFileName())
            Console.WriteLine(" Line Number: {0}", _
               st.GetFrame(0).GetFileLineNumber().ToString())
            
            Console.WriteLine()
            Console.WriteLine("-------------------------------------------------")
            Console.WriteLine()
         End Try
      End Sub
   End Class
End Namespace 'StackFramePublic 

Namespace SampleInternal
   
   Public Class ClassLevel1
      
      Public Sub InternalMethod()
         Try
            Dim nestedClass As New ClassLevel2
            nestedClass.Level2Method()
         Catch e As Exception
            Console.WriteLine(" InternalMethod exception handler")
            
            ' Build a stack trace from one frame, skipping the 
            ' current frame and using the next frame.  By default,
            ' file and line information are not displayed.
            Dim st As New StackTrace(New StackFrame(1))
            Console.WriteLine(" Stack trace for next level frame: {0}", _
               st.ToString())
            Console.WriteLine(" Stack frame for next level: ")
            Console.WriteLine("   {0}", st.GetFrame(0).ToString())
            
            Console.WriteLine(" Line Number: {0}", _
               st.GetFrame(0).GetFileLineNumber().ToString())
            
            Console.WriteLine()
            Console.WriteLine("   ... throwing exception to next level ...")
            Console.WriteLine("-------------------------------------------------")
            Console.WriteLine()
            Throw e
         End Try
      End Sub
   End Class
   
   Public Class ClassLevel2
      
      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
   End Class
   
   Public Class ClassLevel3
      
      Public Sub Level3Method()
         Try
            Dim nestedClass As New ClassLevel4()
            nestedClass.Level4Method()
         Catch e As Exception
            Console.WriteLine(" Level3Method exception handler")
            
            ' Build a stack trace from a dummy stack frame.
            ' Explicitly specify the source file name and line number.
            Dim st As New StackTrace(New StackFrame("source.cs", 60))
            Console.WriteLine(" Stack trace with dummy stack frame: {0}", _
               st.ToString())
            Dim i As Integer
            For i = 0 To st.FrameCount - 1
               ' Display the stack frame properties.
               Dim sf As StackFrame = st.GetFrame(i)
               Console.WriteLine(" File: {0}", sf.GetFileName())
               Console.WriteLine(" Line Number: {0}", _
                  sf.GetFileLineNumber())
               ' The column number defaults to zero when not initialized.
               Console.WriteLine(" Column Number: {0}", _
                  sf.GetFileColumnNumber())
               If sf.GetILOffset <> StackFrame.OFFSET_UNKNOWN
                  Console.WriteLine(" Intermediate Language Offset: {0}", _
                      sf.GetILOffset())
               End If
               If sf.GetNativeOffset <> StackFrame.OFFSET_UNKNOWN
                 Console.WriteLine(" Native Offset: {0}", _
                     sf.GetNativeOffset())
               End If
            Next i 
            Console.WriteLine()
            Console.WriteLine("   ... throwing exception to next level ...")
            Console.WriteLine("-------------------------------------------------")
            Console.WriteLine()
            Throw e
         End Try
      End Sub
   End Class
   
   Public Class ClassLevel4
      
      Public Sub Level4Method()
         Try
            Dim [nestedClass] As New ClassLevel5()
            [nestedClass].Level5Method()
         Catch e As Exception
            Console.WriteLine(" Level4Method exception handler")
            
            ' Build a stack trace from a dummy stack frame.
            ' Explicitly specify the source file name, line number
            ' and column number.
            Dim st As New StackTrace(New StackFrame("source.cs", 79, 24))
            Console.WriteLine(" Stack trace with dummy stack frame: {0}", _
               st.ToString())
            
            ' Access the StackFrames explicitly to display the file
            ' name, line number and column number properties.
            ' StackTrace.ToString only includes the method name. 
            Dim i As Integer
            For i = 0 To st.FrameCount - 1
               Dim sf As StackFrame = st.GetFrame(i)
               Console.WriteLine(" File: {0}", sf.GetFileName())
               Console.WriteLine(" Line Number: {0}", _
                  sf.GetFileLineNumber())
               Console.WriteLine(" Column Number: {0}", _
                  sf.GetFileColumnNumber())
            Next i
            Console.WriteLine()
            Console.WriteLine("   ... throwing exception to next level ...")
            Console.WriteLine("-------------------------------------------------")
            Console.WriteLine()
            Throw e
         End Try
      End Sub
   End Class
  
   
   Public Class ClassLevel5
      
      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
   End Class
  
   
   Public Class ClassLevel6
      Public Sub Level6Method()
         Throw New Exception("An error occurred in the lowest internal class method.")
      End Sub
   End Class

End Namespace 'StackFrameInternal

설명

스레드 StackFrame 를 실행하는 동안 만들어진 모든 함수 호출에 대해 호출 스택에서 을 만들고 푸시합니다. 스택 프레임에는 항상 정보가 포함 MethodBase 되며 필요에 따라 파일 이름, 줄 번호 및 열 번호 정보가 포함됩니다.

StackFrame 정보는 디버그 빌드 구성에 가장 유익합니다. 기본적으로 디버그 빌드에는 디버그 기호가 포함되지만 릴리스 빌드는 그렇지 않습니다. 디버그 기호에는 개체 생성 StackFrame 에 사용되는 대부분의 파일, 메서드 이름, 줄 번호 및 열 정보가 포함됩니다.

생성자

StackFrame()

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

StackFrame(Boolean)

필요에 따라 소스 정보를 캡처하고 StackFrame 클래스의 새 인스턴스를 초기화합니다.

StackFrame(Int32)

현재 스택 프레임 위의 프레임에 해당하는 StackFrame 클래스의 새 인스턴스를 초기화합니다.

StackFrame(Int32, Boolean)

필요에 따라 소스 정보를 캡처하고 현재 스택 프레임 위의 프레임에 해당하는 StackFrame 클래스의 새 인스턴스를 초기화합니다.

StackFrame(String, Int32)

지정된 파일 이름과 줄 번호만 포함하는 StackFrame 클래스의 새 인스턴스를 초기화합니다.

StackFrame(String, Int32, Int32)

지정된 파일 이름, 줄 번호 및 열 번호만 포함하는 StackFrame 클래스의 새 인스턴스를 초기화합니다.

필드

OFFSET_UNKNOWN

네이티브 또는 MSIL(Microsoft Intermediate Language) 오프셋을 알 수 없을 때 GetNativeOffset() 또는 GetILOffset() 메서드를 통해 반환되는 값을 정의합니다. 이 필드는 상수입니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetFileColumnNumber()

실행 중인 코드를 포함하는 파일에서 열 번호를 가져옵니다. 이 정보는 일반적으로 실행 파일의 디버깅 기호에서 추출됩니다.

GetFileLineNumber()

실행 중인 코드를 포함하는 파일에서 줄 번호를 가져옵니다. 이 정보는 일반적으로 실행 파일의 디버깅 기호에서 추출됩니다.

GetFileName()

실행 중인 코드를 포함하는 파일 이름을 가져옵니다. 이 정보는 일반적으로 실행 파일의 디버깅 기호에서 추출됩니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetILOffset()

실행 중인 메서드의 MSIL(Microsoft Intermediate Language) 코드 시작 부분에서 오프셋을 가져옵니다. 이 오프셋은 JIT(just-in-time) 컴파일러가 디버깅 코드를 생성하는지 여부에 따라 근사값이 될 수 있습니다. 이 디버깅 정보의 생성은 DebuggableAttribute에 의해 제어됩니다.

GetMethod()

프레임이 실행되고 있는 메서드를 가져옵니다.

GetNativeOffset()

실행 중인 메서드의 네이티브 JIT(just-in-time) 컴파일 코드 처음부터 계산한 오프셋을 가져옵니다. 이 디버깅 정보의 생성은 DebuggableAttribute 클래스를 통해 제어됩니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

읽을 수 있도록 스택 추적을 만듭니다.

확장 메서드

GetNativeImageBase(StackFrame)

이 스택 프레임이 실행되는 네이티브 이미지의 기준 주소에 대한 포인터를 반환합니다.

GetNativeIP(StackFrame)

실행되는 메서드에 대한 네이티브 코드의 시작 부분에 대한 인터페이스 포인터를 가져옵니다.

HasILOffset(StackFrame)

실행 중인 메서드의 IL 코드 처음부터 오프셋을 사용할 수 있는지를 나타냅니다.

HasMethod(StackFrame)

지정된 프레임이 실행되는 메서드에 대한 정보를 사용할 수 있는지 여부를 나타냅니다.

HasNativeImage(StackFrame)

네이티브 이미지를 지정한 스택 프레임에 사용할 수 있는지를 나타냅니다.

HasSource(StackFrame)

지정한 스택 프레임이 실행되는 코드가 포함된 파일을 사용할 수 있는지 여부를 나타냅니다.

적용 대상

추가 정보