VB.Net Tutorial/Development/StackTrace

Материал из VB Эксперт
Перейти к: навигация, поиск

Print Stack TraceImports System.Diagnostics

public class Test
   public Shared Sub Main
        CalculateEmployeeSalaries()
   End Sub
    Private Shared Sub CalculateEmployeeSalaries()
        CheckVacationPay()
    End Sub
    Private Shared Sub CheckVacationPay()
        ShowCallStack()
    End Sub

    Private Shared Sub ShowCallStack()
        Dim stack_trace As New System.Diagnostics.StackTrace(True)
        For i As Integer = 0 To stack_trace.FrameCount - 1
            With stack_trace.GetFrame(i)
                Console.WriteLine("Method: " & .GetMethod().ToString)
                Console.WriteLine("File: " & .GetFileName())
                Console.WriteLine("Line: " & .GetFileLineNumber())
            End With
        Next i
    End Sub
End class
Method: Void ShowCallStack()
File:
Line: 0
Method: Void Main()
File:
Line: 0