Now I am debugging a buggy VB.NET function like following
Function foo()
Try
‘ many loops and codes and nested try catch here!
……
Catch (ex as Exception)
Msgbox ex.message
Finally
…
end try
End function
My headache is: when it causes an exception, it’s very hard for me to locate
which line causes the error. I remember if I use the “On Error Goto
Err_Hanlder” method, I can always use a simple “Resume” statement to help me
locate the buggy line. But I heard the VB’s “On Error GoTo” is not
recommended and also remember I can only use the ”try catch” in C#, C++ or
Java.
Question: Is there an easy method to achieve the same effect as the resume
(I mean for debugging purpose)? or can I set the IDE to break at the buggy
line instead of at the catch block? Is this a legitimate reason that favor
“On Error Goto” more than “Try Catch”?
Look forward your insight.
James 5 1406
James,
In VS 2003 you can break into the debugger when an exception is thrown.
From the Debug menu, choose Exceptions. From the Exceptions dialog select
Common Language Runtime Exceptions. Click the radio button to break into the
debugger when an exception is thrown.
Now when an exception is thrown the debugger will highlight the line causing
the exception, even though the code is within a Try Catch block.
Kerry Moorman
"James Ma" wrote: Now I am debugging a buggy VB.NET function like following
Function foo() Try ‘ many loops and codes and nested try catch here! …… Catch (ex as Exception) Msgbox ex.message Finally … end try End function
My headache is: when it causes an exception, it’s very hard for me to locate which line causes the error. I remember if I use the “On Error Goto Err_Hanlder” method, I can always use a simple “Resume” statement to help me locate the buggy line. But I heard the VB’s “On Error GoTo” is not recommended and also remember I can only use the ”try catch” in C#, C++ or Java.
Question: Is there an easy method to achieve the same effect as the resume (I mean for debugging purpose)? or can I set the IDE to break at the buggy line instead of at the catch block? Is this a legitimate reason that favor “On Error Goto” more than “Try Catch”?
Look forward your insight. James
Thank you so much. It's working, though I'm using VS2005.
"Kerry Moorman" wrote: James,
In VS 2003 you can break into the debugger when an exception is thrown.
From the Debug menu, choose Exceptions. From the Exceptions dialog select Common Language Runtime Exceptions. Click the radio button to break into the debugger when an exception is thrown.
Now when an exception is thrown the debugger will highlight the line causing the exception, even though the code is within a Try Catch block.
Kerry Moorman
"James Ma" wrote:
Now I am debugging a buggy VB.NET function like following
Function foo() Try ‘ many loops and codes and nested try catch here! …… Catch (ex as Exception) Msgbox ex.message Finally … end try End function
My headache is: when it causes an exception, it’s very hard for me to locate which line causes the error. I remember if I use the “On Error Goto Err_Hanlder” method, I can always use a simple “Resume” statement to help me locate the buggy line. But I heard the VB’s “On Error GoTo” is not recommended and also remember I can only use the ”try catch” in C#, C++ or Java.
Question: Is there an easy method to achieve the same effect as the resume (I mean for debugging purpose)? or can I set the IDE to break at the buggy line instead of at the catch block? Is this a legitimate reason that favor “On Error Goto” more than “Try Catch”?
Look forward your insight. James
> Now I am debugging a buggy VB.NET function like following My headache is: when it causes an exception, it's very hard for me to locate which line causes the error. I remember if I use the "On Error Goto Err_Hanlder" method, I can always use a simple "Resume" statement to help me locate the buggy line. But I heard the VB's "On Error GoTo" is not recommended and also remember I can only use the "try catch" in C#, C++ or Java.
Another alternative you can do is to add line numbers to your code and retrieve
the last successful line using the ERL() function (see http://msdn.microsoft.com/library/de...lproperty.asp).
This function has been in VB but undocumented between versions 3 and 6. It
is now documented again.
See http://devauthority.com/blogs/jwoole...12/21/661.aspx for
a sample implementation.
Jim Wooley
And another alternative is, instead of displaying the exception message in a
message box, write the exception itself to the console:
Console.Writeline(ex.ToString())
This will give you the stack trace which in turn will show you the name of
the source file and the line number along with the procedure name.
"James Ma" <Ja*****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com... Now I am debugging a buggy VB.NET function like following
Function foo() Try many loops and codes and nested try catch here! Catch (ex as Exception) Msgbox ex.message Finally end try End function
My headache is: when it causes an exception, its very hard for me to locate which line causes the error. I remember if I use the On Error Goto Err_Hanlder method, I can always use a simple Resume statement to help me locate the buggy line. But I heard the VBs On Error GoTo is not recommended and also remember I can only use the try catch in C#, C++ or Java.
Question: Is there an easy method to achieve the same effect as the resume (I mean for debugging purpose)? or can I set the IDE to break at the buggy line instead of at the catch block? Is this a legitimate reason that favor On Error Goto more than Try Catch?
Look forward your insight. James
Wow! Thanks! This is truly an amazing tip.
I love MS.
--
-C. Moya www.cmoya.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I double-checked the path to my error log. It is in
/var/www/logs/php_error_log
Thanks. :)
-Wayne Stevenson
|
by: Kenneth |
last post by:
Hello,
I'm having some serious problems debugging a script that I'm trying to make
work. I'm working on a form where a user can type in a time (in the format
of HH:MM), and another script automatically calculate how much time is
inbetween.
That part of it is working fine, but what ISN'T working fine is the script
that validates whether...
|
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: Spacen Jasset |
last post by:
The main two desirable things I feel error handling should provide are
these:
1) Debugging and diagnostic aid
2) User feedback
One method that is used a fair amount it to 'say' that all functions must
return an error code of a standard type, for example tError. Where tError is
typedefed as a long int. A list of error codes may then be...
|
by: Steve - DND |
last post by:
I was wondering if anyone can point me to some articles or practices they
use for dealing with errors in their applications; particularly in an n-tier
design. I am trying to find one way to conveniently handle both soft and
hard errors, primarily for display to the end user.
One method I have considered is rethrowing exceptions. With this...
| |
by: Jos Joye |
last post by:
Hello,
I'm currently reading the MS Developing Web applications with c# (and
VB.net).
In the chapter related to Error management, there is a sample about
"Page-Level Error Pages"
eg:
In my form:
========
|
by: Ryan Ternier |
last post by:
I'm having an issue with an SQL insert statement. It's a very simple
statement, and it's causing too much fuss.
strSQL = "INSERT INTO tblFieldLayouts(TypeID, FieldID, OrderID, Hidden)
VALUES(" & intTypeID & ", " & intFieldID & ", " & intOrderID & ",0)"
comFields.CommandText = strSQL
comFields.ExecuteNonQuery()
|
by: OHM |
last post by:
Hi everyone,
I have a problem with error handling and wondered if anyone has managed to
implement a global exception handling model.
Is it possible to ensure that you see all exceptions before it becomes an
unhandled exception.
This is opposale to putting Try Catches around every statement
|
by: poojamangal |
last post by:
I want to upload images or pdf files. but i m unable to do so. i got error. please help me to sort it out..
my code is:
<%
'on error resume next
Class FreeASPUpload
Public UploadedFiles
Public FormElements
Private VarArrayBinRequest
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |