StackFrameとは? わかりやすく解説

StackFrame クラス

名前空間: Microsoft.JScript
アセンブリ: Microsoft.JScript (microsoft.jscript.dll 内)
構文構文

Public NotInheritable Class
 StackFrame
    Inherits ScriptObject
    Implements IActivationObject
public sealed class StackFrame : ScriptObject,
 IActivationObject
public ref class StackFrame sealed : public
 ScriptObject, IActivationObject
public final class StackFrame extends ScriptObject
 implements IActivationObject
public final class StackFrame extends
 ScriptObject implements IActivationObject
継承階層継承階層
System.Object
   Microsoft.JScript.ScriptObject
    Microsoft.JScript.StackFrame
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame クラス

現在のスレッドコール スタック上で関数呼び出しを表す、StackFrame に関する情報提供します

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class StackFrame
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class StackFrame
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class StackFrame
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class StackFrame
SerializableAttribute 
ComVisibleAttribute(true) 
public class StackFrame
解説解説
使用例使用例

StackFrame作成して使用する方法次のコード例示します

Imports System
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 'Main
   End Class 'ConsoleApp
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 'InternalMethod
   End Class 'ClassLevel1
   
   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 'Level2Method
   End Class 'ClassLevel2
   
   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 'Level3Method
   End Class 'ClassLevel3
   
   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 'Level4Method 
   End Class 'ClassLevel4
  
   
   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 'Level5Method
   End Class 'ClassLevel5 
  
   
   Public Class ClassLevel6
      Public Sub Level6Method()
         Throw New Exception("An
 error occurred in the lowest internal class method.")
      End Sub 'Level6Method
   End Class 'ClassLevel6 

End Namespace 'StackFrameInternal
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.");
      }

   }
}
#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();
}

package SamplePublic;

import System.*;
import System.Diagnostics.*;
import SampleInternal.*;

// This console application illustrates various uses
// of the StackTrace and StackFrame classes.
class ConsoleApp
{
    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        ClassLevel1 mainClass = new ClassLevel1();

        try {
            mainClass.InternalMethod();
        }
        catch (System.Exception exp) {
            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}", 
                Convert.ToString(st.GetFrame(0).GetFileLineNumber()));
            Console.WriteLine();
            Console.WriteLine("---------------------------------------------"
                + "----\n");
        }
    } //main
} //ConsoleApp
継承階層継承階層
System.Object
  System.Diagnostics.StackFrame
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame コンストラクタ ()


StackFrame コンストラクタ (String, Int32, Int32)

指定したファイル名行番号、および列番号だけを含む新しい StackFrame オブジェクト初期化します。

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

StackFrame コンストラクタ使用するコード例次に示します

   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 '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;
}
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;
}


try {
    ClassLevel5 nestedClass = new ClassLevel5();
    nestedClass.Level5Method();
}
catch (System.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.jsl",
 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.get_FrameCount();
 i++) {
        StackFrame sf = st.GetFrame(i);
        Console.WriteLine(" File: {0}", sf.GetFileName());
        Console.WriteLine(" Line Number: {0}", 
            (Int32)sf.GetFileLineNumber());
        Console.WriteLine(" Column Number: {0}", 
            (Int32)sf.GetFileColumnNumber());
    }
    Console.WriteLine();
    Console.WriteLine(" ... throwing exception to next level...");
    Console.WriteLine("---------------------------------------------"
        + "----\n");
    throw e;
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame コンストラクタ (Int32, Boolean)

現在のスタック フレーム上のフレーム対応する新しい StackFrame オブジェクト初期化しオプションソース情報キャプチャます。

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    skipFrames As Integer, _
    fNeedFileInfo As Boolean _
)
Dim skipFrames As Integer
Dim fNeedFileInfo As Boolean

Dim instance As New StackFrame(skipFrames,
 fNeedFileInfo)
public StackFrame (
    int skipFrames,
    bool fNeedFileInfo
)
public:
StackFrame (
    int skipFrames, 
    bool fNeedFileInfo
)
public StackFrame (
    int skipFrames, 
    boolean fNeedFileInfo
)
public function StackFrame (
    skipFrames : int, 
    fNeedFileInfo : boolean
)

パラメータ

skipFrames

スキップするスタック上のフレーム数。

fNeedFileInfo

ファイル名行番号、および列番号をキャプチャする場合trueそれ以外場合false

使用例使用例

StackFrame コンストラクタ使用するコード例次に示します

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 'Level2Method
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;
   }
}
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() throws System.Exception
{
    try {
        ClassLevel3 nestedClass = new ClassLevel3();
        nestedClass.Level3Method();
    }
    catch (System.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;
    }
} //Level2Method
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame コンストラクタ


StackFrame コンストラクタ (Int32)

現在のスタック フレーム上のフレーム対応する新しい StackFrame オブジェクト初期化します。

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    skipFrames As Integer _
)
Dim skipFrames As Integer

Dim instance As New StackFrame(skipFrames)
public StackFrame (
    int skipFrames
)
public:
StackFrame (
    int skipFrames
)
public StackFrame (
    int skipFrames
)
public function StackFrame (
    skipFrames : int
)

パラメータ

skipFrames

スキップするスタック上のフレーム数。

使用例使用例

StackFrame コンストラクタ使用するコード例次に示します

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 'InternalMethod
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;
   }
}
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;
   }

}

public void InternalMethod() throws System.Exception
{
    try {
        ClassLevel2 nestedClass = new ClassLevel2();
        nestedClass.Level2Method();
    }
    catch (System.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}", 
            Convert.ToString(st.GetFrame(0).GetFileLineNumber()));
        Console.WriteLine();
        Console.WriteLine(" ... throwing exception to next level...");
        Console.WriteLine("-------------------------------------------"
            + "------\n");
        throw e;
    }
} //InternalMethod
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame コンストラクタ (Boolean)

新しい StackFrame オブジェクト初期化しオプションソース情報キャプチャます。

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    fNeedFileInfo As Boolean _
)
Dim fNeedFileInfo As Boolean

Dim instance As New StackFrame(fNeedFileInfo)
public StackFrame (
    bool fNeedFileInfo
)
public:
StackFrame (
    bool fNeedFileInfo
)
public StackFrame (
    boolean fNeedFileInfo
)
public function StackFrame (
    fNeedFileInfo : boolean
)

パラメータ

fNeedFileInfo

ファイル名行番号、および列番号をキャプチャする場合trueそれ以外場合false

使用例使用例

StackFrame コンストラクタ使用するコード例次に示します

<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 'Main
[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");
     }
 }
[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"
 );
   }

}

/** @attribute STAThread()
 */
public static void main(String[]
 args)
{
    ClassLevel1 mainClass = new ClassLevel1();

    try {
        mainClass.InternalMethod();
    }
    catch (System.Exception exp) {
        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}", 
            Convert.ToString(st.GetFrame(0).GetFileLineNumber()));
        Console.WriteLine();
        Console.WriteLine("---------------------------------------------"
            + "----\n");
    }
} //main
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame コンストラクタ (String, Int32)

指定したファイル名行番号だけを含む新しい StackFrame オブジェクト初期化します。

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

StackFrame コンストラクタ使用するコード例次に示します

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 'Level3Method
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;
   }
}
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 void Level3Method() throws System.Exception
{
    try {
        ClassLevel4 nestedClass = new ClassLevel4();
        nestedClass.Level4Method();
    }
    catch (System.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.jsl", 60));
        Console.WriteLine(" Stack trace with dummy stack frame: {0}", 
            st.ToString());
        for (int i = 0; i < st.get_FrameCount();
 i++) {
            // Display the stack frame properties.
            StackFrame sf = st.GetFrame(i);
            Console.WriteLine(" File: {0}", sf.GetFileName());
            Console.WriteLine(" Line Number: {0}", (
                Int32)sf.GetFileLineNumber());

            // Note that the column number defaults to zero
            // when not initialized.
            Console.WriteLine(" Column Number: {0}", 
                (Int32)sf.GetFileColumnNumber());
            if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
 {
                Console.WriteLine(" Intermediate Language Offset: {0}",
 
                    (Int32)sf.GetILOffset());
            }
            if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN)
 {
                Console.WriteLine(" Native Offset: {0}", 
                    (Int32)sf.GetNativeOffset());
            }
        }  
        Console.WriteLine();
        Console.WriteLine(" ... throwing exception to next level...");
        Console.WriteLine("--------------------------------------------"
            + "-----\n");
        throw e;
    }
} //Level3Method
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackFrame フィールド


パブリック フィールドパブリック フィールド

  名前 説明
パブリック フィールド OFFSET_UNKNOWN ネイティブまたは MSIL (Microsoft Intermediate Language) オフセット未確認場合に、GetNativeOffset または GetILOffset から返される値を定義します。このフィールド定数です。
参照参照

StackFrame フィールド


パブリック フィールドパブリック フィールド

  名前 説明
パブリック フィールド closureInstance  
パブリック フィールド engine  ( ScriptObject から継承されます。)
パブリック フィールド localVars  
参照参照

関連項目

StackFrame クラス
Microsoft.JScript 名前空間

StackFrame プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Item  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック プロパティ UnderlyingSystemType  ( ScriptObject から継承されます。)
参照参照

関連項目

StackFrame クラス
Microsoft.JScript 名前空間

StackFrame メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetDefaultThisObject  
パブリック メソッド GetField オーバーロードされます。  
パブリック メソッド GetFields  ( ScriptObject から継承されます。)
パブリック メソッド GetGlobalScope  
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetMember オーバーライドされます。  
パブリック メソッド GetMembers オーバーライドされます。  
パブリック メソッド GetMemberValue  
パブリック メソッド GetMethod  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック メソッド GetMethods  ( ScriptObject から継承されます。)
パブリック メソッド GetParent  ( ScriptObject から継承されます。)
パブリック メソッド GetProperties  ( ScriptObject から継承されます。)
パブリック メソッド GetProperty  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド InvokeMember  ( ScriptObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 Microsoft.JScript.IActivationObject.GetLocalField  
参照参照

関連項目

StackFrame クラス
Microsoft.JScript 名前空間

StackFrame メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetFileColumnNumber 実行しているコード格納しているファイル列番号を取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetFileLineNumber 実行しているコード格納しているファイル行番号取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetFileName 実行中のコード格納しているファイル名取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetILOffset 実行中のメソッドMSIL (Microsoft Intermediate Language) コード先頭からのオフセット取得します。このオフセットジャスト イン タイム (JIT: Just-In-Time) コンパイラデバッグするコード生成しているかどうか依存する近似値になることがあります。このデバッグ情報生成は、DebuggableAttribute プロパティにより制御されます。
パブリック メソッド GetMethod フレーム実行しているメソッド取得します
パブリック メソッド GetNativeOffset 実行中のメソッドネイティブ JIT コンパイル コード先頭からのオフセット取得します。このデバッグ情報生成は、DebuggableAttribute プロパティにより制御されます。
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString オーバーライドされますスタック トレース読み取り可能な形式構築します
プロテクト メソッドプロテクト メソッド
参照参照

StackFrame メンバ

StackFrame データ型公開されるメンバを以下の表に示します


パブリック フィールドパブリック フィールド
  名前 説明
パブリック フィールド closureInstance  
パブリック フィールド engine  ( ScriptObject から継承されます。)
パブリック フィールド localVars  
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Item  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック プロパティ UnderlyingSystemType  ( ScriptObject から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetDefaultThisObject  
パブリック メソッド GetField オーバーロードされます。  
パブリック メソッド GetFields  ( ScriptObject から継承されます。)
パブリック メソッド GetGlobalScope  
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetMember オーバーライドされます。  
パブリック メソッド GetMembers オーバーライドされます。  
パブリック メソッド GetMemberValue  
パブリック メソッド GetMethod  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック メソッド GetMethods  ( ScriptObject から継承されます。)
パブリック メソッド GetParent  ( ScriptObject から継承されます。)
パブリック メソッド GetProperties  ( ScriptObject から継承されます。)
パブリック メソッド GetProperty  オーバーロードされます。 ( ScriptObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド InvokeMember  ( ScriptObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 Microsoft.JScript.IActivationObject.GetLocalField  
参照参照

関連項目

StackFrame クラス
Microsoft.JScript 名前空間

StackFrame メンバ

現在のスレッドコール スタック上で関数呼び出しを表す、StackFrame に関する情報提供します

StackFrame データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック フィールドパブリック フィールド
  名前 説明
パブリック フィールド OFFSET_UNKNOWN ネイティブまたは MSIL (Microsoft Intermediate Language) オフセット未確認場合に、GetNativeOffset または GetILOffset から返される値を定義します。このフィールド定数です。
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetFileColumnNumber 実行しているコード格納しているファイル列番号を取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetFileLineNumber 実行しているコード格納しているファイル行番号取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetFileName 実行中のコード格納しているファイル名取得します通常、この情報実行可能ファイルデバッグ シンボルから抽出されます。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetILOffset 実行中のメソッドMSIL (Microsoft Intermediate Language) コード先頭からのオフセット取得します。このオフセットジャスト イン タイム (JIT: Just-In-Time) コンパイラデバッグするコード生成しているかどうか依存する近似値になることがあります。このデバッグ情報生成は、DebuggableAttribute プロパティにより制御されます。
パブリック メソッド GetMethod フレーム実行しているメソッド取得します
パブリック メソッド GetNativeOffset 実行中のメソッドネイティブ JIT コンパイル コード先頭からのオフセット取得します。このデバッグ情報生成は、DebuggableAttribute プロパティにより制御されます。
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString オーバーライドされますスタック トレース読み取り可能な形式構築します
プロテクト メソッドプロテクト メソッド
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「StackFrame」の関連用語

StackFrameのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StackFrameのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS