新しい 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
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0