473,387 Members | 1,529 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.

Exception is not caught by .net framework

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
2 1169
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jacek Dziedzic | last post by:
Hi! In my main() function I have a last-resort exception construct that looks like this: int main() { try { // ... program code }
14
by: Nenad Dobrilovic | last post by:
Hi, Is it possible for exception object to be aware of it's throwing? I want to log in the text file when exeption is thrown, not when the exception object is created (because I can create...
9
by: David B | last post by:
Why is it so difficult to report bugs to Microsoft? I have a documented bug and an small test example. I don't really see why I should have to pay to tell them about it... Anyway, the...
5
by: Nathan Wiegman | last post by:
Using the XmlSerializer to deserialize a double.NaN value generates an exception in the framework which the framework then catches. This is super undesirable in our application, because our...
6
by: Vadivel Kumar | last post by:
I've a problem in handling a custom exception The following is my custom exception class: public class AppException : public Exception { public AppException (string message, Exception...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
5
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded...
3
by: CharlieC | last post by:
I am writing a windows C# application, and I want to ensure that all exceptions, handled or otherwise, are logged to the local event log. I can do this for the handled exceptions, but I am not sure...
7
by: Sek | last post by:
Hi Folks! I was pondering over a code and noticed that exception handlers were present in the private, protected as well as public methods. And, ofcourse, public methods were calling priv/prot...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.