How to get hold of the linenumber of the line where an error occurred

Hi. I have tried ( in vain ), when executing the VB executable,

to find out how to show the line number of the error that occurs.

I can access the line number when I'm in the VB IDE environment, but not when I run the executable.

Below is the code I use to access the line number

( I also triedlo_stacktrace.ToString(), but again the line number did not show when I ran the executable )

This leads me to the question: Is it at all possible to access the line number when the executable is run ?

PrivateFunction CodeRef(ByVal po_ModInfoAs t_ModInfo _

,ByVal po_exAs Exception _

,ByVal pb_ReturnSourceAsBoolean _

,ByVal pl_FrameNoAsLong _

)AsString

Dim lo_stackframeAs StackFrame

Dim ls_CodeRefAsString

lo_stackframe =New StackTrace(po_ex,True).GetFrame(pl_FrameNo)

If (pb_ReturnSource)Then

ls_CodeRef = po_ex.Source

Else

ls_CodeRef =""

EndIf

ls_CodeRef = ls_CodeRef _

&"." & po_ModInfo.ModuleName _

&"." & lo_stackframe.GetMethod.Name _

&" ( " & lo_stackframe.GetFileLineNumber &" )"

Return ls_CodeRef

EndFunction

[3322 byte] By [haguna99] at [2007-12-28]
# 1

Try dropping the corresponding symbols (.pdb) file next to your executable.

Best regards,
Johan Stenberg

MSJohanStenberg at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...