Showing posts with label Silverlight 4. Show all posts
Showing posts with label Silverlight 4. Show all posts

May 23, 2011

Silverlight 4 - catching uncaught exceptions from external components

I was playing with an external component in Silverlight 4 and got an unhandled exception while debugging.

The problem was that I wasn't able to see what's going on because the debugger won't show anything (it doesn't have the source of the exception) and because the exception was triggered internally in event in the component trying to catch it to see what is the exception had no effect as well.

Then I opened the App.xaml file and found the following:

if (!System.Diagnostics.Debugger.IsAttached)

Pretty neat, huh? :).
The method signature was as following:
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

All I needed to do now was to put a breakpoint on the if statement and then expect the ApplicationUnhandledExceptionEventArgs.ExceptionObject to see what the exception was.

Thought you may have some hard times debugging problems with Silverlight.