title: how to log Unhandled Exception in Silverlight 5
body: <p>I would like to capture and log unhandled exceptions that occur in my Silverlight 5 application.  I already have wired up the Application.UnhandledException delegate.  The question is, after an exception has been thrown, what can and what can't I do?  This Silverlight application is running in a C++ application that is hosting the WebControl (IE's engine) and this host is implementing the external function.  So this is what the Application.UnhandledException's function looks like:</p>
  
  <pre><code>private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  {
      var ex = e.ExceptionObject;
  
      // This is a reference to the 
      var external = External.Instance;
  
      // loop through all the exceptions and call the hosts 'external' method so the
      // host is able to write out the error to a local log file
      while (external != null &amp;&amp; ex != null)
      {
          external.LogException(ex.Message, ex.StackTrace);
          ex = ex.InnerException;
      }
  
      // If the app is running outside of the debugger then report the exception using
      // a ChildWindow control.
      if (!System.Diagnostics.Debugger.IsAttached)
      {
          // NOTE: This will allow the application to continue running after an exception has been thrown
          // but not handled. 
          // For production applications this error handling should be replaced with something that will 
          // report the error to the website and stop the application.
          e.Handled = true;
          ChildWindow errorWin = new ErrorWindow(e.ExceptionObject);
          errorWin.Show();
      }
  }
  </code></pre>
  
  <p>The goal is to log the error and keep the application running.</p>