StackTrace コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > StackTrace コンストラクタ ()の意味・解説 

StackTrace コンストラクタ ()

StackTrace クラス新しインスタンス呼び出し元のフレームから初期化します。

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

解説解説
使用例使用例

スタック トレース内の最初最後関数呼び出し表示するコード例次に示します

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

}

public void Level5Method() throws System.Exception
{
    try {
        ClassLevel6 nestedClass = new ClassLevel6();
        nestedClass.Level6Method();
    }
    catch (System.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.get_FrameCount() > 1) {
            // Display the highest-level function call 
            // in the trace.
            sf = st.GetFrame(st.get_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;
    }
} //Level5Method
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (Exception)

指定した例外オブジェクト使用してStackTrace クラス新しインスタンス初期化します。

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

例外例外
例外種類条件

ArgumentNullException

e パラメータnull 参照 (Visual Basic では Nothing) です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (StackFrame)

単一フレーム格納している StackTrace クラス新しインスタンス初期化します。

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

解説解説
使用例使用例

スタック トレース情報イベント ログ エントリに書き込むコード例次に示します

Dim frame As New StackFrame(1,
 True)
Dim strace As New StackTrace(frame)
            

EventLog.WriteEntry(frame.GetMethod().Name, _
                    strace.ToString(), _
                    EventLogEntryType.Warning)
StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
                    st.ToString(),
                    EventLogEntryType.Warning);
StackFrame^ fr = gcnew StackFrame( 1,true );
StackTrace^ st = gcnew StackTrace( fr );
EventLog::WriteEntry( fr->GetMethod()->Name, st->ToString(), EventLogEntryType::Warning
 );
StackFrame fr = new StackFrame(1, true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().get_Name(), st.ToString(),
    EventLogEntryType.Warning);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (Boolean)

StackTrace クラス新しインスタンス呼び出し元のフレームから初期化しオプションソース情報キャプチャます。

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

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

Dim instance As New StackTrace(fNeedFileInfo)
public StackTrace (
    bool fNeedFileInfo
)
public:
StackTrace (
    bool fNeedFileInfo
)
public StackTrace (
    boolean fNeedFileInfo
)

パラメータ

fNeedFileInfo

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

解説解説
使用例使用例

さまざまな StackTrace コンストラクタ メソッドコード例次に示します

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

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

指定した例外オブジェクト使用してStackTrace クラス新しインスタンス初期化し指定したフレーム数をスキップしたり、必要に応じてソース情報取得したできます

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

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

Dim instance As New StackTrace(e,
 skipFrames, fNeedFileInfo)
public StackTrace (
    Exception e,
    int skipFrames,
    bool fNeedFileInfo
)
public:
StackTrace (
    Exception^ e, 
    int skipFrames, 
    bool fNeedFileInfo
)
public StackTrace (
    Exception e, 
    int skipFrames, 
    boolean fNeedFileInfo
)
public function StackTrace (
    e : Exception, 
    skipFrames : int, 
    fNeedFileInfo : boolean
)

パラメータ

e

スタック トレース構築する基となる例外オブジェクト

skipFrames

トレース開始するスタックまでのフレーム数。

fNeedFileInfo

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

例外例外
例外種類条件

ArgumentNullException

e パラメータnull 参照 (Visual Basic では Nothing) です。

ArgumentOutOfRangeException

skipFrames パラメータが負の値です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (Exception, Boolean)

指定した例外オブジェクト使用して StackTrace クラス新しインスタンス初期化しオプションソース情報キャプチャます。

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

Public Sub New ( _
    e As Exception, _
    fNeedFileInfo As Boolean _
)
Dim e As Exception
Dim fNeedFileInfo As Boolean

Dim instance As New StackTrace(e,
 fNeedFileInfo)
public StackTrace (
    Exception e,
    bool fNeedFileInfo
)
public:
StackTrace (
    Exception^ e, 
    bool fNeedFileInfo
)
public StackTrace (
    Exception e, 
    boolean fNeedFileInfo
)

パラメータ

e

スタック トレース構築する基となる例外オブジェクト

fNeedFileInfo

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

例外例外
例外種類条件

ArgumentNullException

e パラメータnull 参照 (Visual Basic では Nothing) です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

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

呼び出し元のフレームから StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップしたり、必要に応じてソース情報取得したできます

名前空間: 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 StackTrace(skipFrames,
 fNeedFileInfo)
public StackTrace (
    int skipFrames,
    bool fNeedFileInfo
)
public:
StackTrace (
    int skipFrames, 
    bool fNeedFileInfo
)
public StackTrace (
    int skipFrames, 
    boolean fNeedFileInfo
)
public function StackTrace (
    skipFrames : int, 
    fNeedFileInfo : boolean
)

パラメータ

skipFrames

トレース開始するスタックまでのフレーム数。

fNeedFileInfo

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

例外例外
例外種類条件

ArgumentOutOfRangeException

skipFrames パラメータが負の値です。

解説解説
使用例使用例

さまざまな StackTrace コンストラクタ メソッドコード例次に示します

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ

StackTrace クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
StackTrace () StackTrace クラス新しインスタンス呼び出し元のフレームから初期化します。
StackTrace (Boolean) StackTrace クラス新しインスタンス呼び出し元のフレームから初期化しオプションソース情報キャプチャます。
StackTrace (Exception) 指定した例外オブジェクト使用してStackTrace クラス新しインスタンス初期化します。
StackTrace (Int32) 呼び出し元のフレームから StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップします。
StackTrace (StackFrame) 単一フレーム格納している StackTrace クラス新しインスタンス初期化します。
StackTrace (Exception, Boolean) 指定した例外オブジェクト使用して StackTrace クラス新しインスタンス初期化しオプションソース情報キャプチャます。
StackTrace (Exception, Int32) 指定した例外オブジェクト使用して StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップします。
StackTrace (Int32, Boolean) 呼び出し元のフレームから StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップしたり、必要に応じてソース情報取得したできます
StackTrace (Thread, Boolean) 指定したスレッド用に StackTrace クラス新しインスタンス初期化しオプションソース情報キャプチャます。
StackTrace (Exception, Int32, Boolean) 指定した例外オブジェクト使用してStackTrace クラス新しインスタンス初期化し指定したフレーム数をスキップしたり、必要に応じてソース情報取得したできます
参照参照

StackTrace コンストラクタ (Thread, Boolean)

指定したスレッド用に StackTrace クラス新しインスタンス初期化しオプションソース情報キャプチャます。

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

Public Sub New ( _
    targetThread As Thread, _
    needFileInfo As Boolean _
)
Dim targetThread As Thread
Dim needFileInfo As Boolean

Dim instance As New StackTrace(targetThread,
 needFileInfo)
public StackTrace (
    Thread targetThread,
    bool needFileInfo
)
public:
StackTrace (
    Thread^ targetThread, 
    bool needFileInfo
)
public StackTrace (
    Thread targetThread, 
    boolean needFileInfo
)
public function StackTrace (
    targetThread : Thread, 
    needFileInfo : boolean
)

パラメータ

targetThread

スタック トレース要求するスレッド

needFileInfo

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

例外例外
例外種類条件

ThreadStateException

スレッド targetThread中断されていません。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (Exception, Int32)

指定した例外オブジェクト使用して StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップします。

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

例外例外
例外種類条件

ArgumentNullException

e パラメータnull 参照 (Visual Basic では Nothing) です。

ArgumentOutOfRangeException

skipFrames パラメータが負の値です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StackTrace コンストラクタ (Int32)

呼び出し元のフレームから StackTrace クラス新しインスタンス初期化し指定した数のフレームスキップします。

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

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

Dim instance As New StackTrace(skipFrames)
public StackTrace (
    int skipFrames
)
public:
StackTrace (
    int skipFrames
)
public StackTrace (
    int skipFrames
)

パラメータ

skipFrames

トレース開始するスタックまでのフレーム数。

例外例外
例外種類条件

ArgumentOutOfRangeException

skipFrames パラメータが負の値です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「StackTrace コンストラクタ ()」の関連用語

StackTrace コンストラクタ ()のお隣キーワード
検索ランキング

   

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



StackTrace コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS