473,387 Members | 1,497 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,387 software developers and data experts.

Disable 'continue' option when an unhandled exception occurs?

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
default is to give the user the option to continue, quite frankly. I'm using
Visual Studio 2005.

Thanks,
-SurturZ

Jul 17 '07 #1
5 5113
surturz wrote:
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.
Simple answer - don't leave any exceptions unhandled.
If you do, then control passes over to the user and there's /nothing/
you can do to stop them hitting the "Continue" button.
For example, if there is a bug in the program that causes an exception, I
want the program to crash.
Yes, but not as "far" as that appalling "Oops" dialog.

Add a handler for Application.ThreadException and clean things up in
there. Show the user a sanitised message (in,say, a MessageBox) and
then take the application down completely.

Oh, and watch out for Threads as well; in VB'2005, if an Exception
"escapes" from one of your [background] Threads, it will take the entire
application down with it.
I'm surprised the default is to give the user the option to continue,
quite frankly.
I couldn't agree more. The application will probably be in a really bad
way at this point and to give a user the option to say "Oh well, that
error doesn't matter" is just terrifying.

HTH,
Phill W.
Jul 17 '07 #2
Hi SurturZ,

Thank you for the feedback.

I am not sure if Winform team will remove this continue button in Orcas.
Actually, the Winform team highly recommended the developer to provide a
customized ThreadException handler, so that they can fully control the
crash logic themselves. The reason that the "Continue" button is on by
default is some developers requested this feature for debugging purpose.

Anyway, if you need any further help or have any concern, please feel free
to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 18 '07 #3
Open the project properties. On the "Application" tab, you click the "View
Application Events" button. That will generate a new partial class looking
like this:

Namespace My

' The following events are availble for MyApplication:

'

' Startup: Raised when the application starts, before the startup form is
created.

' Shutdown: Raised after all application forms are closed. This event is not
raised if the application terminates abnormally.

' UnhandledException: Raised if the application encounters an unhandled
exception.

' StartupNextInstance: Raised when launching a single-instance application
and the application is already active.

' NetworkAvailabilityChanged: Raised when the network connection is
connected or disconnected.

Partial Friend Class MyApplication

End Class

End Namespace
Create a handler like this in the MyApplication class:

Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e
As Microsoft.VisualBasic.ApplicationServices.Unhandle dExceptionEventArgs)
Handles Me.UnhandledException

'My.Application.Log.WriteException(e.Exception, TraceEventType.Critical,
"Unhandled Exception.")

MsgBox("An unhandled exception occurred: " & e.Exception.Message &
vbCrLf & vbCrLf & "I'm going to quit now!")

End

End Sub

That should do it.

Cheers,
Johnny J.

"surturz" <su*****@newsgroup.nospamwrote in message
news:FF**********************************@microsof t.com...
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
default is to give the user the option to continue, quite frankly. I'm
using
Visual Studio 2005.

Thanks,
-SurturZ

Jul 18 '07 #4
UnhandledExceptionEventArgs.ExitApplication Property in ApplicationEvents.vb
under VS2005 gives you the ability to not continue

Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e
As Microsoft.VisualBasic.ApplicationServices.Unhandle dExceptionEventArgs)
Handles Me.UnhandledException

' Do your recovery like write to a log file followed by

e.ExitApplication = True

End Sub

"surturz" <su*****@newsgroup.nospamwrote in message
news:FF**********************************@microsof t.com...
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
default is to give the user the option to continue, quite frankly. I'm
using
Visual Studio 2005.

Thanks,
-SurturZ

Jul 18 '07 #5
Hi SurturZ,

Have you reviewed my last reply to you? If you still have anything unclear,
please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 23 '07 #6

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

Similar topics

30
by: Blnukem | last post by:
Hi All I'm new to javascript and was wondering if someone can help me with this I want to disable my second and third drop-box if the first one is selected to "Closed" I think I'm close but just...
3
by: GATMAN | last post by:
Dim f As New frmWeb f.ShowDialog(Me) f.Dispose() Annytime i call a diffrent form from my main form using showdialog, i get an exception eror thrown when i close the form, but when i use f.show i...
2
by: Chris DiPierro | last post by:
Is there a way to disable scroll wheel support in a combobox? Basically, I have a situation where a user chooses an option in a combobox. I'm handling the selected index change event, and due to...
5
by: Peter Steele | last post by:
We have an application that when it runs in the IDE in debug mode an unhandled exception is occurring in a system header file associated with STL stirngs. The actual statement that crashes is ...
4
by: Bill | last post by:
Despite our best efforts occasionally in an aspx file, something like <%=x%> where x is not defined sqeaks by and I get the ugly asp error message. I want to be able to identify this particular...
0
by: Jeff Jarrell | last post by:
I have successfully added new handlers for unhandled exceptions... AddHandler AppDomain.CurrentDomain.UnhandledException, addressof blahblah AddHandler Application.ThreadException, addressof...
5
by: Sam Loveridge | last post by:
Hi All. I'm hoping someone can point me in the direction of a solution to unhandled exceptions in MDI child forms causing the application to crash. I've found various articles describing a...
0
by: K S | last post by:
All, I am getting the following error when I tried to deploy my webpage (Release Version) on Windows Server 2003. The below error occurs when I try to access the webservice. PS: I can access...
1
by: Nathan Sokalski | last post by:
When I click after about 15 minutes on a page I wrote I recieve the following error: Server Error in '/' Application....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.