Solved

VB.Net - Finding Line Where Exception Occurred

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now