By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Exception is not caught by .net framework

P: n/a
Hi all,

I have an application written in VB.net
The application runs perfectly well on my machine. The
application successfully caught all exceptions since I
handled all the exception within the application.

However, after I installed the application on another
machine, the exception didn't get caught. In fact, the
annoying messagebox with the usual message "An unhandled
exception has occurred in your application. If you click
continue, ...". For your information, the application is
installed using installshield and the .net framework is
also installed by the installedshield program.
I have also included App.config file on the application.

Anyone has any idea what could be wrong here?
Any help will be greatly appreciated. Thank you very much.

regards,
Sean
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nak
Hi there,

Try adding the following hander at the applications entry point,

AddHandler Application.ThreadException, AddressOf
application_ThreadException

Private Sub application_ThreadException(ByVal sender As Object, ByVal t As
ThreadExceptionEventArgs)

Do whatever, and call Application.Exit if you decide to shut the
application

End Sub

I've had problems with exceptions not being trapped and this one
resolved those missed.

Nick.

"Sean" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...
Hi all,

I have an application written in VB.net
The application runs perfectly well on my machine. The
application successfully caught all exceptions since I
handled all the exception within the application.

However, after I installed the application on another
machine, the exception didn't get caught. In fact, the
annoying messagebox with the usual message "An unhandled
exception has occurred in your application. If you click
continue, ...". For your information, the application is
installed using installshield and the .net framework is
also installed by the installedshield program.
I have also included App.config file on the application.

Anyone has any idea what could be wrong here?
Any help will be greatly appreciated. Thank you very much.

regards,
Sean

Nov 21 '05 #2

P: n/a
Sean,
In addition to Nak's comments.

Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

For example: In my Windows Forms apps I would have a handler attached to the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the MainForm
raises an exception, the Application.ThreadException handler will catch all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay
"Sean" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...
Hi all,

I have an application written in VB.net
The application runs perfectly well on my machine. The
application successfully caught all exceptions since I
handled all the exception within the application.

However, after I installed the application on another
machine, the exception didn't get caught. In fact, the
annoying messagebox with the usual message "An unhandled
exception has occurred in your application. If you click
continue, ...". For your information, the application is
installed using installshield and the .net framework is
also installed by the installedshield program.
I have also included App.config file on the application.

Anyone has any idea what could be wrong here?
Any help will be greatly appreciated. Thank you very much.

regards,
Sean

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.