Solved

VB.Net - Finding Line Where Exception Occurred

Posted on 2014-01-15
3
204 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET tools for adding thread safety to a web app? 3 48
VB.NET 1 28
Expression Evaluater 3 38
Convert Ctime to date time in textfile? 7 32
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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