Welcome to the Xceed Community | Help
Community Search  
More Search Options

Data Virtualization sporadic exception

Sort Posts: Previous Next
  •  09-28-2009, 10:59 AM Post no. 24194

    Data Virtualization sporadic exception

    I am using the WPF grid with a DataVirtualizing DataSource, and I am having a sporadic exception being thrown that crashes the application.

    The exception is this:

    "An item with the same key has already been added."

    with a stack trace of:

        at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at Xceed.Wpf.DataGrid.VirtualListTableOfContent.AddPage(VirtualPage page)
       at Xceed.Wpf.DataGrid.VirtualList.FillEmptyPage(AsyncQueryInfo asyncQueryInfo, Object[] fetchedItems)
       at Xceed.Wpf.DataGrid.VirtualPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
       at Xceed.Wpf.DataGrid.DataGridPageManagerBase.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
       at Xceed.Wpf.DataGrid.DataGridPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
       at Xceed.Wpf.DataGrid.VirtualPage.AsyncQueryInfo_EndQueryItems(AsyncQueryInfo queryInfo, Object[] fetchedItems)

    This exception is not reproducible reliably. I have a virtualized grid with a page size of 100, maxRealizedItemCount of 1000, and a total count of 5000 records in the data source. I query a WCF service in the QueryItems event handler using the supplied page count and start index. On average, randomly skipping around the result set via the scrollbar will cause the grid to crash after 10-15 page retrievals.

     Has anyone else experienced these intermittent issues with a virtualized data source?

    Thanks!

  •  09-28-2009, 12:05 PM Post no. 24195 in reply to 24194

    Re: Data Virtualization sporadic exception

    After a little more research, I think I found the cause of the bug:

     The objects that I am putting into the grid override Equals and GetHashCode to evaluate equality based on a database primary key instead of based on reference equality. I took these overrides out of the one object I am testing with, and I cannot reproduce the crash error anymore.

    I would like very much to be able to use the virtualizing data source with objects that override Equals() and evaluate equality based on a property value. I think a simple check in the data source to update an entry in the dictionary rather than always trying to add it would fix the issue. Would it be possible to file a defect for this issue?

     Thanks!

  •  09-29-2009, 2:11 PM Post no. 24229 in reply to 24195

    Re: Data Virtualization sporadic exception

    Hi Chris,

    I have submitted a request (case id 127416) to the development team to have this issue investigated. Thank you for bringing this to our attention.

     


    Diane Lafontaine
    Technical Support / Technical Support Team Lead
    Xceed Software Inc.
  •  09-30-2009, 4:50 PM Post no. 24258 in reply to 24195

    Re: Data Virtualization sporadic exception

    Hi Chris,

    Unfortunately, after revision by a lead developer, this is not something that we will change. We work with HashTables/Dictionaries specifically for performance reasons, so it will crash if two items have the same HashCode or are equivalent according to the Equals.

    You would have the same problem in non-virtual mode.

    However, looking at your specific case, we do not understand why you have two items with the same HashCode and Equals which answers the same as the primary key. It's as if you have two objects in your database which have the same primary key, which is odd.

     


    Diane Lafontaine
    Technical Support / Technical Support Team Lead
    Xceed Software Inc.
  •  10-16-2009, 2:24 PM Post no. 24564 in reply to 24258

    Re: Data Virtualization sporadic exception

    If data is being added to the database table while the user is viewing a grid that displays that data, it's possible that subsequent calls to the service that get each page of data may return a record that has already been received previously. (Depending on the sort options, filter options, etc.)

     

     

  •  03-12-2010, 4:14 AM Post no. 26085 in reply to 24258

    Re: Data Virtualization sporadic exception

    Hello Diane,

    You need to take a relook at this problem. I'm having the same problem with XCeed Datagrid (3.6.10075.13300) as the thread starter. I get a TargetInvocationException with a message 'Item has already been added to the collection'. This happens specifically when I scroll to the very bottom of my data virtualized Data Grid. I also tried to write a simple wrapper class to ensure it's not caused by GetHashCode or Equals  methods:

     public class Test
     {
            public Guid Id { get; set; }
            public string Title { get; set; }
            public override int GetHashCode()
            {
                return Id.GetHashCode();
            }
            public override bool Equals(object obj)
            {
                return GetHashCode().Equals(obj.GetHashCode());
            }
     }

     

    Before I wrap my real data objects to this class I also test none of them have an empty or null Id and finally use Distinct() lambda to make sure the collection doesn't contain any duplicates.

    Hope this helps,

     -Erkka

     

  •  04-27-2010, 2:13 PM Post no. 26628 in reply to 26085

    Re: Data Virtualization sporadic exception

    Hi,

    Do we have any updates on this issue if a fix will be provided?

    Thanks,

    Keith

     

  •  05-03-2010, 5:09 PM Post no. 26694 in reply to 26628

    Re: Data Virtualization sporadic exception

    Hi Keith,

    Please refer to my reply earlier in the thread. At this time this issue hasn't been re-opened. If there are reasons for us to re-evaluate the situation, we would need a detailed description and a project sample demonstrating the problematic behavior. Thank you for your understanding.

     


    Diane Lafontaine
    Technical Support / Technical Support Team Lead
    Xceed Software Inc.
  •  08-03-2010, 1:38 PM Post no. 27874 in reply to 24564

    Re: Data Virtualization sporadic exception

    Chris:

    If data is being added to the database table while the user is viewing a grid that displays that data, it's possible that subsequent calls to the service that get each page of data may return a record that has already been received previously. (Depending on the sort options, filter options, etc.)

    Data virtualization with a rapidly changing collection is complex.  I see the same behavior, and I am unsure of how to handle this scenario.  I wrote a test application which continuously adds data to a grid.  If the user scrolls around the grid while data is being added, I can consistently reproduce this exception.  The stacktrace is below:

    "An item with the same key has already been added."
    "   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)\r\n   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)\r\n   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)\r\n   at Xceed.Wpf.DataGrid.VirtualListTableOfContent.AddPage(VirtualPage page)\r\n   at Xceed.Wpf.DataGrid.VirtualList.FillEmptyPage(AsyncQueryInfo asyncQueryInfo, Object[] fetchedItems)\r\n   at Xceed.Wpf.DataGrid.VirtualPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)\r\n   at Xceed.Wpf.DataGrid.DataGridPageManagerBase.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)\r\n   at Xceed.Wpf.DataGrid.DataGridPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)\r\n   at Xceed.Wpf.DataGrid.VirtualPage.AsyncQueryInfo_EndQueryItems(AsyncQueryInfo queryInfo, Object[] fetchedItems)"

    Surely QueryItemsEventArgs has some facility for handling this scenario?

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.