Strange exception in chart

7 posts, 0 answers
  1. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2013 Link to this post

    Hello!

    Sometimes (about 8 times from 10) we have very strange exception with your charts.

    We debuged this exception and got following:

    1) Stack trace exception:

    Index must be within the bounds of the List.
    Parameter name: index
     
        mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) Line 265 + 0x37 bytes    C#
        mscorlib.dll!System.Collections.Generic.List<Telerik.Windows.Controls.Charting.ILogicalItem>.Insert(int index = 2, Telerik.Windows.Controls.Charting.ILogicalItem item = {Telerik.Windows.Controls.Charting.MarkedZone}) Line 276   C#
        mscorlib.dll!System.Collections.ObjectModel.Collection<Telerik.Windows.Controls.Charting.ILogicalItem>.InsertItem(int index, Telerik.Windows.Controls.Charting.ILogicalItem item) Line 91 + 0x2c bytes  C#
        System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<Telerik.Windows.Controls.Charting.ILogicalItem>.InsertItem(int index = 2, Telerik.Windows.Controls.Charting.ILogicalItem item = {Telerik.Windows.Controls.Charting.MarkedZone}) Line 85  C#
        Telerik.Windows.Data!Telerik.Windows.Data.RadObservableCollection<System.__Canon>.InsertItem(int index, System.__Canon item) Line 92 + 0x14 bytes   C#
        Telerik.Windows.Controls.Charting!Telerik.Windows.Controls.Charting.LogicalChildrenCollection.InsertItem(int index, Telerik.Windows.Controls.Charting.ILogicalItem item = {Telerik.Windows.Controls.Charting.MarkedZone}) Line 30 + 0xf bytes   C#
        mscorlib.dll!System.Collections.ObjectModel.Collection<Telerik.Windows.Controls.Charting.ILogicalItem>.Add(Telerik.Windows.Controls.Charting.ILogicalItem item) Line 39 + 0xb bytes C#
        Telerik.Windows.Controls.Charting!Telerik.Windows.Controls.Charting.AnnotationLayer.PrepareContainerForItemOverride(System.Windows.DependencyObject element, object item) Line 26 + 0x25 bytes  C#
        System.Windows.dll!System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(System.Windows.DependencyObject container, object item) Line 321 + 0xc bytes   C#
        System.Windows.dll!System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(System.Windows.DependencyObject container = {Telerik.Windows.Controls.Charting.MarkedZone}) Line 1137 + 0xc bytes C#
        System.Windows.dll!System.Windows.Controls.ItemsControl.AddVisualChild(int containerIndex, System.Windows.DependencyObject container, bool needPrepareContainer) Line 83 + 0x19 bytes   C#
        System.Windows.dll!System.Windows.Controls.ItemsControl.AddContainers() Line 60 + 0x2e bytes    C#
        System.Windows.dll!System.Windows.Controls.ItemsControl.RecreateVisualChildren(System.IntPtr nativeItemsControl) Line 523 + 0x7 bytes   C#
        [Managed to Native Transition] 
        System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element = {Telerik.Windows.Controls.Charting.AnnotationLayer}, System.Windows.Size availableSize) Line 2478 + 0x33 bytes C#
        System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) Line 346 + 0x18 bytes C#
        System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth = 0.0, out float outHeight = 0.0) Line 363 + 0x1b bytes    C#
        [Managed to Native Transition] 
        System.Windows.dll!MS.Internal.XcpImports.UIElement_Measure(System.Windows.UIElement element = {Telerik.Windows.Controls.Charting.AnnotationLayer}, System.Windows.Size availableSize) Line 6310 + 0x2c bytes   C#
        System.Windows.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 638 + 0x15 bytes    C#
        Telerik.Windows.Controls.Charting!Telerik.Windows.Controls.Charting.ClipPanel.MeasureOverride(System.Windows.Size availableSize) Line 41 + 0x3f bytes   C#
        System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth = 0.0, out float outHeight = 0.0) Line 363 + 0x1b bytes    C#
        [Appdomain Transition] 

    2) Method RecreateVisualChildren  of ImemsControl (AnnotaionLayer) called twice.
    At the second time we have:
    - Children count = 2 (items were added last time)
    - The same logic item (Marked zone) try to be added to the layer again.

    3) We got you source code of LogicalChildrenCollection.InsertItem:

    protected override void InsertItem(int index, ILogicalItem item)
            {
                if (item.Parent != null)
                    item.Parent.Children.Remove(item);
     
                base.InsertItem(index, item);
                item.Parent = this.Owner;
            }

    In the second time - item.Parent not null and equals Anotaion Layer to which item inserting.
    So item.Parent.Children is equals to this instance.
    So item is removed from this collection.
    Index = 2 (as collection size before invoke this method).
    So base.InsertItem(2, item) invoked, but collection size is one.
    So exception is thrown.

    After this exception silverlight is crashed.
    What we can do with this or we need to wait your fix this bug?
    Please, help. This is critical issue for us. If you need more info - we try to describe this issue. But we couldn't create separate app with this exception.

    Thanks, Alex.
  2. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 03 Apr 2013 Link to this post

    Any ideas what we can do? This is blocker for our customers.
  3. DevCraft banner
  4. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 04 Apr 2013 Link to this post

    Hi Alex,

    Given only the provided information (Stack Trace) we are not able to reproduce the problem. There are far too many factors may affect this which we will need to check. 
    Could you please open a formal support ticket and attach a small, runnable project reproducing the issue, so our development team can investigate it.

    Thank you for the understanding.

    Regards,
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 04 Apr 2013 Link to this post

    1) We try to create such applcation, but as I said before - now we couldn't create such separate app.
    2) As I show before - I think - this is clear bug in your code (In method LogicalChildrenCollection.InsertItem).
    You remove item from collection and then add to this collection again. But index to insert is incorrect after deleting.
    You don't check that inserting item already in this collection but in my case it's so. As I wrong in my guess?

    Thanks, Alex.
  6. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 09 Apr 2013 Link to this post

    Hello Alex,

    While we regret to hear that you are experiencing issues with our product, I don't think that there is much that we can do in this situation. Surely we can not fix a bug that we can not reproduce. We have not had bug reports about this so far, and I have tried to reproduce the exception, but was unable to. I have attached the project to this post. You can try to modify the project to reproduce the exception and send it back to us for investigation. If you are unable to do so, I suggest you examine the application that uses the chart because it just might be a bug in this application.  

    All the best,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 09 Apr 2013 Link to this post

    Thanks, we try this project.

    But can you answer on the simple question about your LogicalChildrenCollection API:

    Is this correct behaviour if somebody (we or silverlight source) try to add to the collection item that is already part of this collection?
    In my case silverlight method IItemContainerGenerator.GenerateNext return item that is already collection element (I don't know why, but this is fact). And then I get this exception.

    So if this is not correct behaviour - I'll try to get answer about why GenerateNext return such element (not new element) from the silverlight support.

    Thanks, Alex.
  8. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 11 Apr 2013 Link to this post

    Alex,

    The Silverlight architecture is designed in a way that you can not add one visual element twice to the visual tree. This you can check with the very simple code below:
    Canvas c = new Canvas();
    Line l = new Line();
    c.Children.Add(l);
    c.Children.Add(l);

    Here an InvalidOperationException is thrown ("Element is already the child of another element."). When an annotation is added to the same Annotations colleciton twice - the same happens, an exception is thrown. This is consistent with the framework and logically correct.

    The result of adding an annotation twice is an exception, but this is not the bug itself. If there is a bug - it is most probably the result of improper sequence of actions that lead to the annotation being added more than once. Surely we can not fix a bug that we can not reproduce. We must have a working project that recreates this issue so that we can investigate and see where the problem lies. 

    The answer to your question "Is this correct behaviour .." is Yes,  this is correct behavior.

    "..method IItemContainerGenerator.GenerateNext return item that is already collection element..." - this is the startpoint of investigation. It seems that there is an issue within this method that returns an element that is already in the collection.

    Still, we were unable to reproduce this issue, and if you could provide us with an example where this happens - we would gladly start looking for solutions. Thank you for understanding.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner