Solved

VB.Net - Finding Line Where Exception Occurred

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

624 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