Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
Infragistics.AutomationPeers.AutomationPeerProxy TargetInvocationException
posted

Hi,

I am running Infragisitcs 13.1.20131.2406. Whenever I move the WPF Window around, maximize or minimize it in Windows 10, I would get a cross thread issue. 

– MAIN EXCEPTION –
System.Reflection.TargetInvocationException
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 Infragistics.AutomationPeers.AutomationPeerProxy.GetChildrenCore()
at Infragistics.Windows.Automation.Peers.DataPresenter.RecordAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

– INNER EXCEPTION –
System.InvalidOperationException
The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Media.Imaging.BitmapDecoder.ToString()
at System.Windows.Media.Imaging.BitmapFrameDecode.ConvertToString(String format, IFormatProvider provider)
at System.Windows.Media.ImageSource.ToString()
at System.Windows.Controls.ContentControl.ContentObjectToString(Object content)
at System.Windows.Controls.ContentControl.GetPlainText()
at System.Windows.Automation.Peers.FrameworkElementAutomationPeer.GetNameCore()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()

– MAIN EXCEPTION –
System.Reflection.TargetInvocationException
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 Infragistics.AutomationPeers.AutomationPeerProxy.GetChildrenCore()
at Infragistics.Windows.Automation.Peers.DataPresenter.RecordAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

– INNER EXCEPTION –
System.InvalidOperationException
The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Media.Imaging.BitmapDecoder.ToString()
at System.Windows.Media.Imaging.BitmapFrameDecode.ConvertToString(String format, IFormatProvider provider)
at System.Windows.Media.ImageSource.ToString()
at System.Windows.Controls.ContentControl.ContentObjectToString(Object content)
at System.Windows.Controls.ContentControl.GetPlainText()
at System.Windows.Automation.Peers.FrameworkElementAutomationPeer.GetNameCore()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()

Parents
No Data
Reply
  • 370
    Suggested Answer
    posted

    My team has figured out the problem. The cause is similar to WinForm cross thread exception in some way.  What happens was the WPF controls are data-bind to a number of ObversableCollections that were updated by .net remoting worker threads. 

    To fix the issue, I added code to store the Main thread's Dispatcher, and changed the code so that the worker thread need to check the main thread's call Dispatcher.Invoke() if the Dispatcher.CheckAccess() is false.

    This issue was not obvious in the beginning due to:

    A. The crash seems to only happen on a QA Windows 10 32 bit (VM), never see it happen on dev's machine 64 bit.
    B. It only happens when the user moves or resizes the application windows. The stack trace never hits the user code, and it is not crashing at the point when the work thread updates the data.

    While WinForm would crash immediately (CrossThreadException) if the data-bind contents are updated by a non-UI thread, WPF controls or backend code crashes at some other points.

Children
No Data