Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unhandled Exceptions

0 views
Skip to first unread message

Andreas van de Sand

unread,
Jul 4, 2006, 11:44:33 PM7/4/06
to
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


Nicholas Paldino [.NET/C# MVP]

unread,
Jul 5, 2006, 12:14:54 AM7/5/06
to
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]
- m...@spam.guard.caspershouse.com

"Andreas van de Sand" <vinc...@gmail.com> wrote in message
news:%23vV8RV%23nGH...@TK2MSFTNGP05.phx.gbl...

Andreas van de Sand

unread,
Jul 5, 2006, 12:56:34 AM7/5/06
to
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]" <m...@spam.guard.caspershouse.com> wrote in
message news:u68yRm%23nGH...@TK2MSFTNGP04.phx.gbl...

Viktar Zhardzetski

unread,
Sep 13, 2006, 12:14:03 PM9/13/06
to
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.

0 new messages