Parsing the Exception.StackTrace to get line number etc.

  • Thread starter Thread starter Nithi Gurusamy
  • Start date Start date
N

Nithi Gurusamy

Hello All:

I want to parse the string Exception.StackTrace after an exception so that I
can get the line numbers and file names etc. Is it possible to get these
values by someother way without looking at the StackTrace member of
Exception object.

Thanks
Nithi Gurusamy
 
Check out the StackFrame class in the Docs

Dim mClass As New Class1()
Try
mClass.MyMethod()
Catch e As Exception
' Display file and line information, if available.
Dim sf As New StackFrame(True)
Dim st As New StackTrace(sf)
Console.WriteLine(" StackTrace: " & st.ToString())
Console.WriteLine(" Line Number : " &
st.GetFrame(0).GetFileLineNumber())

Console.WriteLine("----------")
End Try

hth
Richard
 
Back
Top