Prev: vb.net generating reports
Next: Hi Larry, Hi Jeff,
From: John on 23 Mar 2010 05:46 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
From: Onur Güzel on 23 Mar 2010 06:07 On Mar 23, 11:46 am, "John" <i...(a)nospam.infovis.co.uk> wrote: > 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 Handle exception in a try-catch block and call stacktrace property as 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
From: Herfried K. Wagner [MVP] on 23 Mar 2010 07:17 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/>
|
Pages: 1 Prev: vb.net generating reports Next: Hi Larry, Hi Jeff, |