Solved

VB.Net - Finding Line Where Exception Occurred

Posted on 2014-01-15
3
207 Views
Last Modified: 2014-03-04
Good Day Experts!

I am trying to figure out where an errorr is occuring in my code when I receive an error.  
I have the traditional Try/Catch/Finally block setup with an exception messagebox.

When I receive this messagebox,  is there a way to get the code to "break" back to the line of code that the error happened?  

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39782818
You cannot break back, but you can break before.

Set a breakpoint on the first line after the Try by clicking in the grey margin on the left of the line or by hitting F9 when the cursor is on the line.

Make sure that you are on Debug mode (not Release) in the Toolbar.

When execution arrive on that line, it will fall in the debugger. Move through the code with F10, and note the last line that executes before jumping into the Catch. That is where the error occurs.

If you cannot find out what the problem is, it might be that this line calls another method that is causing the error. In such case, start moving with F11 before executing that line instead of F10 so that you can go into the called method with the debugger.
0
 
LVL 15

Assisted Solution

by:David L. Hansen
David L. Hansen earned 250 total points
ID: 39782844
There is likely a stacktrace component in your exception object (the "ex" object in the catch block).  Put a breakpoint on the first line inside the catch block and when it hits that just hover your mouse over the "ex" variable and look for the stacktrace (I'd copy the text of it and paste it into a text-editor, then search for the word "line" within what you paste).  Also, just turning on "StackTrace" in your debugger and using that is helpful too.

This may help...even if you are running an older version of VS
http://msdn.microsoft.com/en-us/library/dn194476.aspx
or
Type Ctrl+alt+C while in the debugger
or
In the menu go to: Debug->Windows->CallStack
0
 

Author Comment

by:Jimbo99999
ID: 39786775
Thanks you for your reponses. I will try them out.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question