views:

312

answers:

1

Is there a usable equivalent of AppDomain.UnhandledException for Silverlight? I say usable, because, although the method exists in Silverlight, MSDN has it marked as SecurityCritical.

What I'd like is to receive notification of Exceptions happening on background or ThreadPool threads so that I can log them. Application.UnhandledException was another candidate, but it looks like that only recieves exceptions from the UI thread.

+3  A: 

Are you using Silverlight 3? I just put together a simple SL3 application that showed that Application.UnhandledException was notified on unhandled exceptions from the UI thread, a thread pool thread, a worker thread and a background worker thread.

You may have convinced yourself prematurely. :)

Curt Nichols
Verified the same here. The event is as close as you'll get to an app domain unhandled exception handler in the Silverlight world.
Jeff Wilcox
Thanks for looking into this. I am using Silverlight 3, so I'll check my App again.
Samuel Jack
I do indeed receive events from other threads. I was mislead because the error handling code I installed in Application.UnhandledException tried to display some UI, and of course, it can't because it is called on the thread in which the exception occurred, and not the UI thread - so it was throwing an exception of its own!
Samuel Jack
Awesome--glad you found why. :)
Curt Nichols