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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top