×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Exception class in VFP and VB

Exception class in VFP and VB

Exception class in VFP and VB

(OP)
Colleagues,
In VFP, when I used Try-Catch-End Try construct, I always "caught" an error into Exception object. That Exception class in VFP has two properties which I used every time: LineNo and LineContents.
LineNo - the number of the line in the code that erred;
LineContents - the command/code on that line that erred.
Now, looking at the description of the Exception class in .NET, I do not see anything similar to these two properties.
Where/how can I obtain the info about erred code and line number?
AHWBGA!

Regards,

Ilya

RE: Exception class in VFP and VB

Have a look at the StackTrace property of the exception object - but be aware you cannot get full info from a published program, only when running in debug mode

RE: Exception class in VFP and VB

(OP)
Thank you, StrongM!
This indeed got me line # and erred proc's name.
"be aware you cannot get full info from a published program, only when running in debug mode" - Not sure I follow: page https://docs.microsoft.com/en-us/dotnet/api/system... does not specify that this property's not available for EXE on run time...

Regards,

Ilya

RE: Exception class in VFP and VB

From the full StackTrace class documentation (worth pointing out that Exception.StackTrace is not a StackTrace object, it is just a string representation of one - so Microsoft don't provide the full StackTrace documentation under Exception)

Quote:

StackTrace information will be most informative with Debug build configurations. By default, Debug builds include debug symbols, while Release builds do not. The debug symbols contain most of the file, method name, line number, and column information used in constructing StackFrame and StackTrace objects.

For example here's the output from a debug and a Release build of my test rig app that deliberately raised a trappable error ...

CODE

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a(5) As String
        Try
            a(6) = "spoon"
        Catch ex As Exception
            MsgBox(ex.StackTrace)
        End Try
    End Sub 

Debug:



Release:



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close