> Hi all,
>
[quoted text clipped - 10 lines]
> application so that I could then launch another instance of the service
> and gracefully close down the 'afflicted' app.
Application.ThreadException += new blah....
I'm not sure if you need to do this for each thread you create so it would
be worth testing here. With a service though don't you have a single point
that calls all code so can trap everything there? This is what I have and
don't need to restart the service.
Michael
AlanT - 08 Aug 2007 09:27 GMT
>>Is there a mechanism for catching these "uncaught" exceptions in the
>>application so that I could then launch another instance of the service and
>>gracefully close down the 'afflicted' app.
>Application.ThreadException += new blah....
If that does not catch everything you might also try the
AppDomain.CurrentDomain.UnhandledException += ....
hth,
Alan.
GlennDoten - 09 Aug 2007 14:07 GMT
> Application.ThreadException += new blah....
>
> I'm not sure if you need to do this for each thread you create so it would
> be worth testing here. With a service though don't you have a single point
> that calls all code so can trap everything there? This is what I have and
> don't need to restart the service.
Application.ThreadException is documented as handling any exception that
may occur in the application's UI thread, so there's only one thread
this event applies to. Correct?
I'm wondering if a service application even has a UI thread like a
Windows Forms application does. If not, is there any point in calling
Application.ThreadException in a service application?

Signature
-glenn-
Michael C - 13 Aug 2007 00:18 GMT
> Application.ThreadException is documented as handling any exception that
> may occur in the application's UI thread, so there's only one thread this
[quoted text clipped - 3 lines]
> Forms application does. If not, is there any point in calling
> Application.ThreadException in a service application?
In a service most code will start from a single point which will probably be
a timer, so it's easy to catch any exception there.
Mike Blake-Knox - 13 Aug 2007 17:50 GMT
> In a service most code will start from a single point which will probably be
> a timer, so it's easy to catch any exception there.
Except for thread pool threads and asynchronous callback threads. For instance,
an exception thrown in a handler for completion of a socket receive needs to be
handled in a try/catch handler (or by the handler for
AppDomain.CurrentDomain.UnhandledException) as Allan suggested.
Mike
Michael C - 14 Aug 2007 00:48 GMT
> Except for thread pool threads and asynchronous callback threads. For
> instance,
> an exception thrown in a handler for completion of a socket receive needs
> to be
> handled in a try/catch handler (or by the handler for
> AppDomain.CurrentDomain.UnhandledException) as Allan suggested.
Excellent suggestion. This could be a problem in my service, I noticed some
exceptions not getting handled when I was developing even though I thought
everything should be caught. I think I probably eliminated them just by
fixing whatever was causing the exception but it would definately be worth
me revisiting it. Thanks for the tip.
Michael
I am assuming that you are in .net. If so then above the page level which you seem to be catching there are the application level of global.aspx and also the last level below the server of web.config. Both have error traps that you can use. However, there are some errors that are a the server level that never get to the application and those are handled by the server. Look at Application_Error in global.aspx; and customerrors in the web.config.
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Thanks for this .. I'll give it a shot ...
regards Bob