本文整理汇总了VB.NET中System.Diagnostics.StackTrace.StackTrace构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET StackTrace构造函数的具体用法?VB.NET StackTrace怎么用?VB.NET StackTrace使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Diagnostics.StackTrace
的用法示例。
在下文中一共展示了StackTrace构造函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: 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
示例2: 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
示例3: StackFrame
Dim frame As New StackFrame(1, True)
Dim strace As New StackTrace(frame)
EventLog.WriteEntry(frame.GetMethod().Name, _
strace.ToString(), _
EventLogEntryType.Warning)