|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Finding name of exception methodHi
Is it possible to collect name of method, line, file etc in which exception occurred? I have heard its possible using System.Diagnostics.StackTrace but not sure how. Many Thanks Regards On Mar 23, 11:46 am, "John" <i...@nospam.infovis.co.uk> wrote: Handle exception in a try-catch block and call stacktrace property as> Hi > > Is it possible to collect name of method, line, file etc in which exception > occurred? I have heard its possible using System.Diagnostics.StackTrace but > not sure how. > > Many Thanks > > Regards in the example: ///////////////////////////////////// Try Dim a As Integer = 0 Dim b As Integer = 0 Dim c As Integer = 0 a = a \ c Catch ex As Exception ' View the line, file and method that exception was occured at. MsgBox(ex.StackTrace) End Try ///////////////////////////////////// HTH, Onur GÜZEL Am 23.03.2010 10:46, schrieb John:
> Is it possible to collect name of method, line, file etc in which exception \\\> occurred? I have heard its possible using System.Diagnostics.StackTrace but > not sure how. Dim CurrentStack As New StackTrace() MsgBox("Current method: " & CurrentStack.GetFrame(0).GetMethod().Name) MsgBox("Calling method: " & CurrentStack.GetFrame(1).GetMethod().Name) MsgBox("Line number: " & CStr(CurrentStack.GetFrame(0).GetFileLineNumber())) /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> |
|||||||||||||||||||||||