Codessentials

  • Increase font size
  • Default font size
  • Decrease font size
Home Coding tips .Net Creating a Stacktrace manually

Creating a Stacktrace manually

Sometimes it is required to log the location and the stacktrace even if no exception occured.
Here is a function that returns a stacktrace on demand.
Per default you can use aStepsToSkip = 1 as you are not interested in the fact that the stacktrace started at buildStackTrace but you want the location where this function was called.

Public Shared Function buildStackTrace(Optional ByVal aStepsToSkip As Integer = 1) As String
   Dim stacktrace As New StackTrace(aStepsToSkip, True)
   Return stacktrace.ToString
End Function
 

Bookmark

AddThis Social Bookmark Button

Related Articles


Newsflash

Now we have got some coding tips for the developers amongst you!