1

Resolved

DispatchedEvent Exception Handling (by Ben)

description

Sorry its taken me so long. Heres the stack trace

A first chance exception of type 'System.OperationCanceledException' occurred in mscorlib.dll
An exception of type 'System.OperationCanceledException' occurred in mscorlib.dll but was not handled in user code
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: '15' index in collection change event is not valid for collection of size '0'.
at System.Windows.Data.ListCollectionView.AdjustBefore(NotifyCollectionChangedAction action, Object item, Int32 index)
at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MA first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
ethodBase.Invoke(Object obj, Object[] parameters)
at CoreSystem.Collections.DispatchEvent.DispatchHandler.<>c__DisplayClassc.<Invoke>b__a(Object sender2, EventArgs e) in c:\Users\Ben\Documents\coresystem-e79648a8a5c6_Source\CoreSystem\Collections\DispatchEvent.cs:line 239
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: '16' index in collection change event is not valid for collection of size '0'.
at System.Windows.Data.ListCollectionView.AdjustBefore(NotifyCollectionChangedAction action, Object item, Int32 index)
at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at CoreSystem.Collections.DispatchEvent.DispatchHandler.<>c__DisplayClassc.<Invoke>b__a(Object sender2, EventArgs e)

I "Solved" the problem by wrapping the this.handlerInfo.Invoke() call in the DispatchEvent.Invoke Method in a try-catch block. This solves the problem for me, because I know what the exeption is and i know it's ok to just let it continue. However, I don't feel completely comfortable with the solution because it doesn't expose any method of execption handling to the client code. My first thought on that is some form of error handling delegate that can be set, but I don't know enough about what your design principles and goals are to give too much other advice beyond that, and I don't know the code well enough to make sure it doesn't break. Any ideas would be appriciated! Thanks

Ben

comments

farazmasoodkhan wrote May 17, 2014 at 12:32 AM

Fixed in changeset fc757e3edfbe675b5d15c77be717079b2a0a0a33