Hi everyone,
I've got an application which uses a custom exception handler and to avoid
unhandled exceptions I've got a try{}catch (Exception){} block around the
main Application.Run(...).
Works all good on my machine, whenever something unexpected happens the
exception get caught, logged and it shows a nicer message.
Unfortunately for some reason, this only works on my machine! If i deploy my
project to some other computer I get the .net unhandled exception screen!
how can that be? shouldn't that try/catch catch _everything_?? I'm catching
different types, but the last catch block catches (Exception ex)! How can
anything get around that?
Any suggestions?
Thanks very much.
Cheers
Andreas van de Sand 3 1923
Andreas,
Instead of using a try/catch block around the static Run method, why not
attach to the ThreadException event on the Application? It should give you
a consistent way to catch unhandled exceptions on the UI thread.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Andreas van de Sand" <vi******@gmail.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
Hi everyone,
I've got an application which uses a custom exception handler and to avoid
unhandled exceptions I've got a try{}catch (Exception){} block around the
main Application.Run(...).
Works all good on my machine, whenever something unexpected happens the
exception get caught, logged and it shows a nicer message.
Unfortunately for some reason, this only works on my machine! If i deploy
my project to some other computer I get the .net unhandled exception
screen! how can that be? shouldn't that try/catch catch _everything_?? I'm
catching different types, but the last catch block catches (Exception ex)!
How can anything get around that?
Any suggestions?
Thanks very much.
Cheers
Andreas van de Sand
Hi Nicholas,
thanks very much, exactly what I needed!
Still don't know why I didn't get all exceptions via try/catch, but I guess
it's a lot better this way anyway...
thanks again, much appreciated.
Cheers
Andreas
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:u6****************@TK2MSFTNGP04.phx.gbl...
Andreas,
Instead of using a try/catch block around the static Run method, why
not attach to the ThreadException event on the Application? It should
give you a consistent way to catch unhandled exceptions on the UI thread.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Andreas van de Sand" <vi******@gmail.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
>Hi everyone,
I've got an application which uses a custom exception handler and to avoid unhandled exceptions I've got a try{}catch (Exception){} block around the main Application.Run(...).
Works all good on my machine, whenever something unexpected happens the exception get caught, logged and it shows a nicer message. Unfortunately for some reason, this only works on my machine! If i deploy my project to some other computer I get the .net unhandled exception screen! how can that be? shouldn't that try/catch catch _everything_?? I'm catching different types, but the last catch block catches (Exception ex)! How can anything get around that?
Any suggestions?
Thanks very much.
Cheers Andreas van de Sand
Just to clear up a "it works on my machine" confusion... Unfortunatly both VS
2003 and VS 2005 do treat exceptions differently in debug modes. If you will
try to run your application without debugging ("Start without debugging"), or
just run .exe, you should get the same unhandled exception screen.
--
Thanks,
Viktar Z.
"Andreas van de Sand" wrote:
Hi everyone,
I've got an application which uses a custom exception handler and to avoid
unhandled exceptions I've got a try{}catch (Exception){} block around the
main Application.Run(...).
Works all good on my machine, whenever something unexpected happens the
exception get caught, logged and it shows a nicer message.
Unfortunately for some reason, this only works on my machine! If i deploy my
project to some other computer I get the .net unhandled exception screen!
how can that be? shouldn't that try/catch catch _everything_?? I'm catching
different types, but the last catch block catches (Exception ex)! How can
anything get around that?
Any suggestions?
Thanks very much.
Cheers
Andreas van de Sand This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shravan |
last post by:
Hi,
Does anybody know how to catch unhandled exceptions in
an application.
I have tried using
AppDomain.UnhandledException Event
Application.ThreadException Event
but they were not catching...
|
by: terry |
last post by:
Hi,
Question:
When using Framesets and Server.Transfer in the
Application_Error event handler is there a mechanism to
get the error page to display in the total view of the
browser not just in...
|
by: Frank |
last post by:
Hi,
I made a handler for unhandled errors. But before that is executed, VB.NET
gives me the standard error window. In VB6 there was a setting
(errortrapping) about handling errors
in the design...
|
by: Lucvdv |
last post by:
Can someone explain why this code pops up a messagebox saying the
ThreadAbortException wasn't handled?
The first exception is reported only in the debug pane, as expected.
The second (caused by...
|
by: Samuel R. Neff |
last post by:
When you have an unhandled exception in vb.net how do you view the
exception information in the debugger?
In C# the debugger creates a local variable that points to the
exception and you can...
|
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...
|
by: Colmeister |
last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions
(http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have
attempted to incorporate the features he talks...
|
by: Bob |
last post by:
I MUST be able to trap unhandled exceptions, bring the thread to a routine
that then closes the thread on which the execption occurred without closing
or affecting the other threads. Think of an...
|
by: joseph_gallagher |
last post by:
Hi,
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes,...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
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,...
|
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...
| |