I wanted to log the Exception details Filename , FileLineNo, Method Name (where the exception occured) This is working using the StackTrace class But some times i am getting the File Line No and Method Name as null How shall i track Exception Details all the time when an Exception occur
here is my code
Public Shared Sub LogException(ByVal ex As Exception)
Dim trace As Diagnostics.StackTrace = New Diagnostics.StackTrace(ex, True)
LogInfo(String.Format("Error Message :{0} => Error In :{1} => Line Number :{2} => Error Method:{3}",
ex.Message, trace.GetFrame(0).GetFileName(),
trace.GetFrame(0).GetFileLineNumber(),
trace.GetFrame(0).GetMethod().Name))
End Sub