StackTrace コンストラクタ (Exception)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( Exception e )
public: StackTrace ( Exception^ e )
public StackTrace ( Exception e )
public function StackTrace ( e : Exception )
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (StackFrame)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( StackFrame frame )
public: StackTrace ( StackFrame^ frame )
public StackTrace ( StackFrame frame )
public function StackTrace ( frame : StackFrame )
使用例
スタック トレース情報をイベント ログ エントリに書き込むコード例を次に示します。
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);
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Boolean)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( bool fNeedFileInfo )
public: StackTrace ( bool fNeedFileInfo )
public StackTrace ( boolean fNeedFileInfo )
public function StackTrace ( fNeedFileInfo : boolean )
使用例
さまざまな 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
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Exception, Int32, Boolean)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim e As Exception Dim skipFrames As Integer Dim fNeedFileInfo As Boolean Dim instance As New StackTrace(e, skipFrames, fNeedFileInfo)
結果として得られるスタック トレースは、例外が発生した時点のスタックを説明します。
インスタンスの作成時に、スキップするフレームの数がコール スタック上のフレームの合計数以上の場合は、StackTrace にフレームは含まれません。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Exception, Boolean)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( Exception e, bool fNeedFileInfo )
public: StackTrace ( Exception^ e, bool fNeedFileInfo )
public StackTrace ( Exception e, boolean fNeedFileInfo )
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Int32, Boolean)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
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 )
解説
使用例
さまざまな 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
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
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)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
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 )
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Exception, Int32)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( Exception e, int skipFrames )
public: StackTrace ( Exception^ e, int skipFrames )
public StackTrace ( Exception e, int skipFrames )
StackTrace は、ファイル名、行番号、または列情報を含みません。
結果として得られるスタック トレースは、例外が発生した時点のスタックを説明します。
インスタンスの作成時に、スキップするフレームの数がコール スタック上のフレームの合計数以上の場合は、StackTrace にフレームは含まれません。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ (Int32)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
public StackTrace ( int skipFrames )
public: StackTrace ( int skipFrames )
public StackTrace ( int skipFrames )
public function StackTrace ( skipFrames : int )
解説
StackTrace は、呼び出し元の現在のスレッドで作成され、ファイル名、行番号、および列情報を含みません。
インスタンスの作成時に、スキップするフレームの数がコール スタック上のフレームの合計数以上の場合は、StackTrace にフレームは含まれません。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
StackTrace コンストラクタ ()
アセンブリ: mscorlib (mscorlib.dll 内)
構文
StackTrace は、呼び出し元の現在のスレッドで作成され、ファイル名、行番号、および列情報を含みません。
コール スタックに関するメソッドの概要情報だけを持つ完全なトレースが必要な場合は、この既定のコンストラクタを使用します。
スタック トレース内の最初と最後の関数呼び出しを表示するコード例を次に示します。
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
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- StackTrace コンストラクタのページへのリンク