I have a DLL I created to handle all unknown errors using the
Application.Thr eadException event. I'm asking the user if they want to
terminate the program or continue. This is working like I want. The
program exits when I tell it to terminate, and when I continue, the program
keeps running but the routine that generated the error exited. I want to
take this a step further though. Instead of the routine that generated the
error exiting, I would like it to continue with the next line, or even retry
it if possible in some circumstances.
Any ideas on how to accomplish this?
TIA,
-Matt 5 3941
"Matthew Hood" <Dr***********@ Yahoo.com> schrieb: I have a DLL I created to handle all unknown errors using the Application.Th readException event. I'm asking the user if they want to terminate the program or continue. This is working like I want. The program exits when I tell it to terminate, and when I continue, the program keeps running but the routine that generated the error exited. I want to take this a step further though. Instead of the routine that generated the error exiting, I would like it to continue with the next line, or even retry it if possible in some circumstances.
You could use 'On Error Resume Next' inside the method directly. Notice
that this will maybe prevent the 'ThreadExceptio n' from being thrown.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Matt, take this a step further though. Instead of the routine that generated the error exiting, I would like it to continue with the next line, or even retry it if possible in some circumstances.
Any ideas on how to accomplish this?
Unfortunately there is no "easy" way to do this, as by the time the
Application.Thr eadException handler gets the exception the stack is
completely unwound.
The "best" you could do is to put a Try/Catch around each of the commands
you want retry and have the Catch block retry the Try Block. I find using
Goto in the Catch block the "easiest" way to "Retry".
Something like:
Try
Retry:
'...something
Catch ex as FileNotFoundExc eption
If MessageBox.Show ("File does not exit!", _
Application.Pro ductName, _
MessageBoxButto ns.RetryCancel, _
MessageBoxIcon. Question, _
MessageBoxDefau ltButton.Button 2) _
= DialogResult.Re try Then
GoTo retry
End If
End Try
Instead of the Goto, others have put the entire Try/Catch in a loop...
Hope this helps
Jay
"Matthew Hood" <Dr***********@ Yahoo.com> wrote in message
news:Of******** *****@TK2MSFTNG P09.phx.gbl...I have a DLL I created to handle all unknown errors using the Application.Th readException event. I'm asking the user if they want to terminate the program or continue. This is working like I want. The program exits when I tell it to terminate, and when I continue, the program keeps running but the routine that generated the error exited. I want to take this a step further though. Instead of the routine that generated the error exiting, I would like it to continue with the next line, or even retry it if possible in some circumstances.
Any ideas on how to accomplish this?
TIA, -Matt
Jay, Instead of the Goto, others have put the entire Try/Catch in a loop...
Exactly saves me to write it?
Thanks
:-)
Cor
Thanks for the responses. The On Error is a no-go. I already got Try/Catch
statements around areas I know COULD cause a problem though I didn't think
about using a goto to try again. Not sure how this could be used in my
applicatoin.Thr eadexception handler though.
Thanks again.
-Matt
"Matthew Hood" <Dr***********@ Yahoo.com> wrote in message
news:Of******** *****@TK2MSFTNG P09.phx.gbl... I have a DLL I created to handle all unknown errors using the Application.Th readException event. I'm asking the user if they want to terminate the program or continue. This is working like I want. The program exits when I tell it to terminate, and when I continue, the program keeps running but the routine that generated the error exited. I want to take this a step further though. Instead of the routine that generated the error exiting, I would like it to continue with the next line, or even retry it if possible in some circumstances.
Any ideas on how to accomplish this?
TIA, -Matt
Matthew,
When you see my answer above yours to Martin Ho (when the messages are
sorted on sent date) than you can see a sample of my using it in a loop and
a try and catch block.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: VM |
last post by:
Is it possible to intercept all exception errors into one Try...Catch? I've
tried wrapping Application.Run() in a Try...Catch, but it doesn't seem to
work all the time.
Thanks.
|
by: Jason MacKenzie |
last post by:
I have a production critical windows forms application. I have try catch
blocks everywhere to handle every eventuality. However occasionally, every
couple of months, the application crashes. Its usually a .Net Framework
error message telling me there was an unhandled exception
An example would be last October when the clocks rolled back. My question
is: is there a way to handle an exceptions that might make it through the
error...
|
by: Lucas Tam |
last post by:
Without writing try/catch statements is there a way to have a global error
handler in VB.NET? In ASP.NET there is an application level error handler
inside Global.asax, but is there something similar for VB.NET winform
programs?
Thanks!
--
Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
|
by: Paul Wilson |
last post by:
I want to use Err.Raise() method to raise my own exceptions.
Is this the right way of raising my own exceptions ? (i think this is the
only way).
What is the Error number i can safely use, ensuring that it isn't used by
..NET.
Ie, can i use -100 as a error number??
Ie, -100, -101,-102... etc.
I want to konw if .NET uses negative values as error number?
(because i want a specific list of error numbers, to ensure that they are
|
by: jcrouse |
last post by:
I am using the following code to trap errors in a sub routine:
Try
Executable code
Catch ex As Exception
Dim strInputE As String = Application.StartupPath & "\Error.txt"
Dim srE As StreamWriter = File.AppendText(strInputE)
srE.WriteLine(vbCr)
srE.WriteLine(vbCr)
srE.WriteLine(DateTime.Now)
| |
by: sm |
last post by:
Hi,
I have a couple of questions with regards to handling errors and exceptions.
1. If I use
On Error goto Errhandler
...
Errhandler:
|
by: Mesan |
last post by:
Has anyone else noticed that even though you handle an exception that
happens within the background worker that the UnhandledException event
still fires?
For example, here's my ThreadException hookup and code :
Application.ThreadException += new
ThreadExceptionEventHandler(Application_ThreadException);
void Application_ThreadException(object sender,
|
by: =?Utf-8?B?c3VydHVyeg==?= |
last post by:
Hi,
I feel like a noob for asking this.
When I publish a VB windows application, I want to disable the ability of
the the user to continue when there is an unhandled exception.
For example, if there is a bug in the program that causes an exception, I
want the program to crash. If there is an unhandled exception the program is
in an undefined state, and continuing could be dangerous. I'm surprised the
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
Hi,
My C# application trys to access directorycontext during Form loading. Try
and Catch if there is an exception. I then output an error message and then
"this.Close();" to exit the application. But, as my applicaiton closes, the
MS dialog comes up asking to send Error Report to MS.
I tried using ThreadException event code from:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx
But I'm...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |