The Brain Dump

My brain poured out on paper (or so to speak)

Silverlight debugging tip

Silverlight debugging tip

  • Comments 1

I'm building a Deep Zoom application and have been frustrated when it often has some stupid bug (my own of course) and the whole app just disappears. Eventually I realized a quick and dirty snippet I plan to drop into every future Silverlight app. Its not a replacement for the debugger, but its great when you hit an unanticipated snarl and dont have the debugger attached.

 In the application file (typically App.xaml.cs) just hook the unhandled exception handler into the browsers alert function.

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
     System.Windows.Browser.
HtmlPage.Window.Alert(e.ExceptionObject.ToString());
}

A very simple change, but anything you dont anticipate gets popped up in the browser. Of course, you might want to wrap it in a "#if DEBUG" statement to prevent accidentally shipping the final version that way!

  • Very helpful tip Ben, thank you!

Page 1 of 1 (1 items)