Why don't you use the
StackTrace
property from the exception parameter? there's also no need for the
try/catch
block in this instance.
Public Shared Sub LogInfo(ByVal ex As Exception)
Dim fileNames As String = "UNKNOWN"
Dim lineNumber As Int32 = -1
If ex IsNot Nothing then
fileNames = ex.StackTrace.GetFrame((ex.StackTrace.FrameCount - 1)).GetFileName()
lineNumber = ex.StackTrace.GetFrame((ex.StackTrace.FrameCount - 1)).GetFileLineNumber()
End If
Info("Error In" + fileNames + "Line Number" + lineNumber.ToString() + "Error Message" + ex.Message)
End Sub