Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert ein neues StackFrame-Objekt und zeichnet bei Bedarf Quellinformationen auf.
Namespace: System.Diagnostics
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub New ( _
fNeedFileInfo As Boolean _
)
'Usage
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
)
Parameter
- fNeedFileInfo
true, wenn Dateiname, Zeilennummer und Spaltennummer aufgezeichnet werden sollen, andernfalls false.
Beispiel
Im folgenden Codebeispiel wird eine Verwendungsmöglichkeit eines StackFrame-Konstruktors veranschaulicht.
<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
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
StackFrame-Klasse
StackFrame-Member
System.Diagnostics-Namespace