In my App() initialization code, I include a generic handler
UnhandledException += Application_UnhandledException;
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
Debugger.Break();
}
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
{System.Windows.ApplicationUnhandledExceptionEventArgs} base {System.EventArgs}: {System.Windows.ApplicationUnhandledExceptionEventArgs}
ExceptionObject: {System.ArgumentException: Value does not fall within the expected range.}
Handled: false
and if I remove the UnhandledException and set the Debugger to break on unhandled, I get the following:
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Windows.Markup.XamlParseException: 2028 An error has occurred. [Line: 0 Position: 0] ---> 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&Version=4.0.60531.0&File=mscorlib.dll&Key=Arg_ArgumentException
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection
even if I set e.handled = true, my application crashes.
Important Note:
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
My questions are:
Any way to determine what is causing it?
Any way to prevent it?
What is the best way to recover from this error?
Followup:
The problem was solved by naming the view control, even though that should not be needed
from
to