Our main application is WinForm based and we have been using the interoperability classes to host WPF controls in WinForm windows. We currently have a WinForm window that has a WPF control containing a XamGrid and a WinForm DataGridView. On what seems to be random occasions (we have not found a way to reproduce the issue on demand, it has happened while accessing another WinForm window as well as sorting on the DataGridView of the same form and other times as well), we get the stack trace shown below. The last line is the only part of our application code we can look at, and that is just the spot where we spawned the WinForm off into its own UI thread:
public static void RunForm(Form form) { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); try { Application.Run(form); } catch (Exception ex) { ShowException(ex); form.Dispose(); } finally { Application.ThreadException -= new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); } }
From looking at the names in the stack trace
at Infragistics.Controls.Grids.Primitives.RowsPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize)
...
at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right) at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
Seems like the form is trying to get items to re-draw for whatever reason and the XamGrid is trying to apply a sort on items in the grid, but they are not a comparable type, so an error is thrown. Definitely the items in the XamGrid are not comparable (they are System.Windows.COntrols.RichTextBox objects), however, this error happens even when the XamGrid is empty.
Any idea what may be going on here? We are using Infragistics WPF4 version 15.1.1.20151.2008.
Full Stack Trace:
System.ArgumentException: At least one object must implement IComparable. at System.Collections.Comparer.Compare(Object a, Object b) at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2) at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right) at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at Infragistics.DataManager`1.ApplyClientDataManipulations(Boolean setSortedFilteredDataSource) at Infragistics.DataManager`1.ResolveFilteredSortedPagedDataSource() at Infragistics.DataManagerBase.InvalidateSortedFilterdDataSource() at Infragistics.DataManagerBase.GetRecord(Int32 recordIndex) at Infragistics.Controls.Grids.RowsManager.GetDataItem(Int32 index) at Infragistics.Collections.BindableItemCollection`1.GetItem(Int32 index) at Infragistics.Collections.CollectionBase`1.System.Collections.IList.get_Item(Int32 index) at Infragistics.Controls.Grids.Primitives.RowBaseCollection.get_Item(Int32 index) at Infragistics.Controls.Grids.Primitives.RowsPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at EnergyEndeavors.Util.RunForm(Form form) in c:\Projects\VS\Util.cs:line 174
Hello Gary,
Thank you for your post!
I have been investigating into this issue, but as of yet, I have not been able to reproduce the behavior you are seeing. I am going to continue to investigate this issue, but first, could you please provide the type of data source you are using with the XamGrid, as well as any other details with respect to the properties you are setting on it so that I can try to reproduce this more accurately? Also, which version of Infragistics WPF are you using?
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Just checking in, did you still require assistance on this matter?
We can not reproduce this problem on demand so it is difficult to determine what might be happening here. We are currently doing a trial version of our application with v15.1.20151.2055 to see if the issue goes away.