473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with Debugging

I'm hoping someone can help me out with using the Visual Studio IDE for
debugging.

I'm working on a Windows Forms application (it's an MDI if it matters), and
I'm trying to fix a bug in my program. What's happening is
when the program is running, it runs into an exception error and switches
back to the Visio Studio screen. The problem is that it's not
showing me the line of code which actually caused the exception. Instead it
is showing the code for my startup form there is a green arrow
beside the "Public Class frmMain" line at the top of the code. How do I
have VS automatically jump to the line which caused the exception?

I've figured out where the problem is happening, by putting some breaks in.
I have a break before the line which is causing the exception
(this line is in the code of a different form, frmParts.vb, not frmMain.vb)
When it hits the break, it switches back to VS and highlights the
line with the break in frmParts. I press Step Into, it runs the line of
code, and then comes back to VS and highlights the next line in frmParts
(this is the line that's causing the exception). When I press Step Into
again, it runs the code, and comes back to VS with the dailog "An
unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in
system.windows.forms.dll" That is fine, but now it's
highlighting the "Public Class frmMain" in frmMain.vb. I want it to be
highlighting the line which caused the exception, not the Public
Class line of the parent form.

In case it matters, the build type is set to "Debugging", not "Release"

Is there a problem with the way I'm trying to do debugging here? Please
keep in mind that I'm not asking for help with what's causing the
exception errors, I'm asking for help in the debugging process.

Any suggestions are appreicated.
Nov 21 '05 #1
4 1508
Maybe I should also mention that the debugger used to act the way I wanted
it to (highlight the line that caused the exception upon breaking), but then
for some reason it started doing what I have described (green arrow) - so I
have a feeling it's an option somewhere maybe?

I looked through the MSDN library, and all I've been able to figure out is
that the green arrow has something to do with the call stack. I have no
clue what to do about it through.
Nov 21 '05 #2
Jason Hunt wrote:
The problem is that it's not
showing me the line of code which actually caused the exception.


Do you have the IDE set to break on exceptions?

Select Debug>Exceptions from the menu, and select the "Common Language
Runtime Exceptions" item in the list. Then in the "When the exception is
thrown" box, select "Break into the debugger."

This will cause the code to break immediately any exception occurs, allowing
you to see exactly where it happened.

--

(O) e n o n e
Nov 21 '05 #3
The green arrow just means that the error is happening on a line of code in
the block being called by the line that the green arrow is pointing to.

You could put a breakpoint where the green arrow is, re-run the code, and
use F11 to get to the called block. If you use Try blocks in all your
routines, and use the StackTrace property of the exception, you should be on
your way to resolving errors more quickly.

"Jason Hunt" wrote:
Maybe I should also mention that the debugger used to act the way I wanted
it to (highlight the line that caused the exception upon breaking), but then
for some reason it started doing what I have described (green arrow) - so I
have a feeling it's an option somewhere maybe?

I looked through the MSDN library, and all I've been able to figure out is
that the green arrow has something to do with the call stack. I have no
clue what to do about it through.

Nov 21 '05 #4
Hi Guys,

Thanks for the assistance. It turns out that what I described (green arrow
pointing to startup form instead of actual line of code) was only happening
when the exception was caused outside of the startup form's class. I have a
"business objects" class which does all the underlying work, and then the
forms for all the UI stuff which open instances of the business class. The
form was calling a function in the business class, and it there was a
missing bracket in an SQL query.

Charlies' suggestion of using Try/Catch narrowed it down.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
5
by: Jerry Polyak | last post by:
Can someone give me a pointer, please. I am getting the following errors: Notice: Undefined index: sender_name in c:\program files\apache group\apache\htdocs\allinone_form.php on line 12 ...
6
by: Ken Varn | last post by:
I am trying to remote debug a C# application but the debugger is reporting the following exception: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module....
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
4
by: Martin Odhelius | last post by:
Hello, I have a very fustrating problems while debugging ASP.NET applications. When I am debugging and stepping thru code (with F10 or F11) Visual Studio some times suddenly just stop responding...
7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
23
by: keyser_Soze | last post by:
I have MS Visual Studio 2003 on Windows XP Pro. I have IIS running on this machine and I am trying to debug some existing code which has both ASP and ASP.NET components. When I try and launch...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
4
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm working on a web app in VS2005 (.net 2.0.50727). All is working fine, except when I add a HTTPModule to my web.config file, as follows... <httpModules> <add name="UrlRewrite"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.