What appears to be an impossible exception

3 posts, 0 answers
  1. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 16 May 2013 Link to this post

    This exception doesn't make any sense and it is happening all behind the scenes in Telerik code in another thread and crashes the application.

    It is stating that Telerik.Windows.Controls.GridView.ColumnGroupDescriptor is not a Telerik.Windows.Data.IGroupDescriptor which is impossible.  If you review the ColumnGroupDescriptor code it extends GroupDescriptorBase, which implements IGroupDescriptor interface.  So that exception doesn't make any sense as it seems completely impossible for this to occur.

    So I would think that the exception TEXT is wrong and something else is occurring.

    I am using WPF 2013.1.0220.45 controls.

    I hook up to the RadGridView's Grouping event that calls this method on a grouping attempt.

    private void GridView_Grouping(object sender, GridViewGroupingEventArgs e)
    {
        var columnGroupDescriptor = e.GroupDescriptor as ColumnGroupDescriptor;
     
        if (columnGroupDescriptor != null && searchResultsDataGrid.GroupDescriptors.Count == 0)
        {
            var functions = columnGroupDescriptor.Column.AggregateFunctions;
     
            if (functions.Count == 0)
                functions.Add(new CountFunction() { ResultFormatString = "({0})" });
        }
    }

    This doesn't directly throw any exceptions it just is the trigger that eventually causes it to be thrown elsewhere.

    This by the way used to work just find in the 2010 Q3 release of the WPF controls and only occurs when upgrading from those to the latest 2013 release. As you can see this solution discussed in this thread.

    Love to know more about what is going on under the covers and what may be really going on here to find the real issue so that a new solution can be found to provide the CountFunction as a user groups.  I looked at the latest docs and you can do all this in XAML but it forces it to group, it doesn't show how to do set these aggregate functions to be used only when a USER triggers grouping which is the goal to provide group aggregated data for what the user is doing.

    System.ArgumentException was unhandled
      HResult=-2147024809
      Message=The value "Telerik.Windows.Controls.GridView.ColumnGroupDescriptor" is not of type "Telerik.Windows.Data.IGroupDescriptor" and cannot be used in this generic collection.
    Parameter name: value
      Source=WindowsBase
      ParamName=value
      StackTrace:
           at System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
           at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
           at Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
           at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
           at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
           at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
           at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
           at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
           at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
           at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
           at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
           at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformGrouping(IGroupDescriptor descriptor, Nullable`1 insertionIndex, GroupingEventAction action)
           at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass3e.<RequestGrouping>b__3d()
           at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
           at Telerik.Windows.Controls.GridView.GridViewDataControl.RequestGrouping(IGroupDescriptor descriptor, Nullable`1 insertionIndex, GroupingEventAction action)
           at Telerik.Windows.Controls.GridView.DragDropController.OnGroupPanelDrop(Object sender, DragEventArgs e)
           at Telerik.Windows.DragDrop.DragEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
           at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at Telerik.Windows.DragDrop.IInputElementExtensions.RaiseEvent(DependencyObject d, RoutedEventArgs routedEventArgs)
           at Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnDragEventHandler(Object sender, DragEventArgs e)
           at Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnDrop(Object sender, DragEventArgs e)
           at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at System.Windows.OleDropTarget.RaiseDragEvent(RoutedEvent dragEvent, Int32 dragDropKeyStates, Int32& effects, DependencyObject target, Point targetPoint)
           at System.Windows.OleDropTarget.MS.Win32.UnsafeNativeMethods.IOleDropTarget.OleDrop(Object data, Int32 dragDropKeyStates, Int64 point, Int32& effects)
           at MS.Win32.UnsafeNativeMethods.DoDragDrop(IDataObject dataObject, IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
           at System.Windows.OleServicesContext.OleDoDragDrop(IDataObject dataObject, IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
           at System.Windows.DragDrop.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects)
           at Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset)
           at Telerik.Windows.DragDrop.DragInitializer.StartDrag()
           at Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(UIElement sender)
           at Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(Object sender, MouseEventArgs e)
           at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
           at System.Windows.Input.InputManager.ProcessStagingArea()
           at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
           at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
           at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at System.Windows.Interop.HwndSource.InputFilterMessage(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 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Window.ShowHelper(Object booleanBox)
           at System.Windows.Window.ShowDialog()
  2. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 16 May 2013 Link to this post

    Update, this occurs even when I take the grouping event away with a grid with just some data. SO my grouping event was just a red herring for this.  So it is just related to the new RadGridView replacing the much older one. Everything seems to work great just grouping throws an exception. I checked and I am not doing anything in XAML or code behind that should be impacting grouping.
  3. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 16 May 2013 Link to this post

    Found what is the REAL underlying issue.

    The object I have in the CollectionView that the Grid is bound to was overriding GethHashCode and the Equality methods and operators When I comment out this code it doesn't throw this exception any more.

    This is very odd, that I cannot override these methods, it must be a requirement inside the CollectionView that it expects this to work as the default object implementations. This is the last thing I would expect to be the issue for THAT exception message. 
Back to Top