KeyNotFound

4 posts, 0 answers
  1. Yoan
    Yoan avatar
    17 posts
    Member since:
    Jan 2012

    Posted 30 Mar 2012 Link to this post

    Hello , my problem is the following : 

    I refresh data in a period of time , and when my data is refreshed i get this exception :

    {System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Telerik.Windows.Controls.Scheduling.HierarchicalGroupInfoAdapter.get_Item(GroupKey key)
       at Telerik.Windows.Controls.GanttView.GanttGroupsDataSource.<GetGroupsForItem>b__0(GroupKey key)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
       at Telerik.Windows.Controls.GanttView.RowHighlightingAndSelectionData.GetHierarchicalItemForEvent(Object e)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
       at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Core.SelectionChanger`1.SynchronizeInternalSelection()
       at Telerik.Windows.Core.SelectionChanger`1.End()
       at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsChanged(NotifyCollectionChangedAction action, IList newItems, IList oldItems)
       at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Core.BatchObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
       at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnInsertItems(Int32 index, IList items)
       at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnItemsAddedToSourceCollection(Int32 startIndex, IEnumerable addedItems)
       at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Core.CollectionChangedHelper.OnTargetCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at WavePortal.Modules.SafetySupervision.ViewModels.SafetySupervisionViewModel.<>c__DisplayClass6.<_safetySupervisionProxy_GetAllPtwsCompleted>b__4()}

    I have the problem only when the GanttView is visible , which menas that the problem is not in my collection.
    I refresh the ItemsSource of the GanttView in this way :

    Collection.Clear();
    foreach ( ... )
    {
    Collection.Add(item);
    }
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 02 Apr 2012 Link to this post

    Hi Yoan,

    Thank you for reporting us this problem. I was able to reproduce it and we scheduled the fix it for the 2012 Q2 release. For now you could work-around the problem by replacing the whole collection instead of using an ObservableCollection.

    Hope this helps.

    Regards,
    Miroslav Nedyalkov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Rahul
    Rahul avatar
    10 posts
    Member since:
    Mar 2013

    Posted 19 Apr 2013 Link to this post

    Hi Miroslav,
                           Even I am encountering the same problem.As mentioned by you, I even tried taking all the items into a seperate collection and then binding to the TaskSource only once. This is happening only when the gantt-view tab is open. Otherwise it won't throw any error. Can you please specify the version od the dlls in which it is fixed? And also can you provide the link in which this issue is fixed and the beta dll.

    Following is my code. And also I have attached the wordfile in which the stack trace and the error is copy pasted. Please help us on this ASAP.

       
    foreach

     

     

    (string item in class)

     

    {

     

     

    sampleData sd = new sampleData();

     

     

     

    string[] sample_id = sample_id.Split('+');

     

    class.itemId = sample_id[0];

    class.itemUniqueId = sample_id;

    class.SeriesData = e.Result.Select(n =>

     

    new Series()

     

    {

    Minutes = n.Minutes,

    Date = n.Date,

    item = sd.itemid,

    StartDate = n.strtdate,

    EndDate = n.enddate,

    }).ToList<

     

    Series>();

     

     

     

    if ((ServiceResult != null) && (ServiceResult.Count > 0))

     

    {

     

     

    var lst = new ObservableCollection<GanttTask>();

     

     

     

    foreach (var item in ServiceResult)

     

    {

     

     

    int difference = item.strtdatetime.Day - day;

     

     

     

    int monthdifference = item.strtdatetime.Month - month;

     

     

     

    int yeardifference = item.strtdatetime.Year - year;

     

     

     

    GanttTask t = new GanttTask() { Start = item.strtdatetime.AddDays(-difference).AddMonths(-monthdifference).AddYears(-yeardifference), End = item.enddatetime.AddDays(-difference).AddMonths(-monthdifference).AddYears(-yeardifference), Title = item.JobId + " @ " + item.CycleDate.ToShortDateString(), Description = "Day " };

     

    lst.Add(t);

    }

    Tasks = lst;

    }

     

     

    if (Series != null)

     

    {

     

     

    seriesData test = (from t in Series

     

     

     

    where t.itemUniqueId == sd.itemUniqueId

     

     

     

    select t).FirstOrDefault();

     

     

     

    if (test == null)

     

    Series.Add(test);

    }


    Thanks,
    Rahul

  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 19 Apr 2013 Link to this post

    Hi Rahul,

    This issue was fixed in the 2012 Q2 release. Could you please check the latest version of RadControls for Silverlight?

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top