title: How to recover from a Silverlight UnhandledException
body: <p>In my App() initialization code, I include a generic handler</p>
  
  <pre><code>UnhandledException += Application_UnhandledException;
  
  private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  {
  Debugger.Break();
  }
  </code></pre>
  
  <p>I have 2 screens that work fine, but when navigating quickly back and forth between the two screens a number of times (varies between 7 and 12) I hit this breakpoint with the exception</p>
  
  <pre><code>{System.Windows.ApplicationUnhandledExceptionEventArgs}   base {System.EventArgs}:   {System.Windows.ApplicationUnhandledExceptionEventArgs}  
      ExceptionObject: {System.ArgumentException: Value does not fall within the expected range.}  
      Handled: false  
  </code></pre>
  
  <p>and if I remove the UnhandledException and set the Debugger to break on unhandled, I get the following:  </p>
  
  <pre><code>Unhandled Error in Silverlight Application  
  Code: 4004  
  Category: ManagedRuntimeError  
  Message: System.Windows.Markup.XamlParseException: 2028 An error has occurred. [Line: 0 Position: 0] ---&gt; System.ArgumentException: [Arg_ArgumentException]  
  Arguments:  Debugging resource strings are unavailable.  
  Often the key and arguments provide sufficient information to diagnose the problem.  
  See http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=4.0.60531.0&amp;File=mscorlib.dll&amp;Key=Arg_ArgumentException  
  at MS.Internal.XcpImports.CheckHResult(UInt32 hr)  
  at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection  
  </code></pre>
  
  <p>even if I set <code>e.handled = true</code>, my application crashes.</p>
  
  <p><strong>Important Note:</strong><br>
  The application, under a MVVM framework works over 99.9% of the time, navigating between dozens of screens.  Only one user has reported being able to crash the application by quickly navigating between two screens, and then only after about 10 back and forth tries</p>
  
  <p>My questions are: </p>
  
  <p>Any way to determine what is causing it?</p>
  
  <p>Any way to prevent it?</p>
  
  <p>What is the best way to recover from this error?  </p>