This is a migrated thread and some comments may be shown as answers.

[Solved] 2010/Q1: NullReferenceException in DataBindingHelper

11 Answers 262 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jani
Top achievements
Rank 1
Jani asked on 16 Mar 2010, 09:53 AM
Hi Telerik,

Using the 2010/Q1 Release, I have a NullReferenceException in DataBindingHelper.AssignMappingFiledTypes() in case of en empty ItemsSource (ItemsSource and SeriesMapping declaration in XAML).

This works fine under 2009/Q3.

[Edited 17:00] Issue appears also within the latest internal build 2010.1.0312.

Cheers,
Jani

11 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 18 Mar 2010, 02:18 PM
Hello Jani,

Please, set the FieldType properties of all ItemMappings with the corresponding types. That should fix it.

Kind regards,
Ves
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jani
Top achievements
Rank 1
answered on 18 Mar 2010, 03:19 PM
Hi Ves,

How can I set the FieldType within XAML?

Cheers,
Jani
0
Vic
Top achievements
Rank 2
answered on 18 Mar 2010, 03:26 PM
Looking for the XAML solution as well, thanks.
0
Ves
Telerik team
answered on 22 Mar 2010, 01:50 PM
Hello,

I am afraid, this is not available at the moment. I have notified our developers of this issue so they will research the possibilities to fix it. Please, accept our apologies for the inconvenience.

Kind regards,
Ves
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vic
Top achievements
Rank 2
answered on 23 Mar 2010, 08:36 PM
Hi Ves,

When we bind there is a good chance that some of the series are null.. the base collection chartSeries houses the individual dictionaries and is the ItemSource for the chart.

var chartSeries = new ObservableCollection<Dictionary<DateTime, double>>(); 
var priceHistory = new Dictionary<DateTime, double>(); 
var buyAction = new Dictionary<DateTime, double>(); 
var sellAction = new Dictionary<DateTime, double>(); 
var shortAction = new Dictionary<DateTime, double>(); 
var coverAction = new Dictionary<DateTime, double>(); 

when lets say buyAction and sellAction are empty, a nullref exception is raised:

System.NullReferenceException occurred
  Message="Object reference not set to an instance of an object."
  StackTrace:
       at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessZoomScrollSettings(QueryableCollectionView dataEngine, ZoomScrollSettings zoomScrollSettings, SeriesMapping seriesMapping, Boolean isValueDateTime, AxisRangeState axisXRangeState)
  InnerException: 

Thinking that it might be a type issue I tried your suggestion and implemented it in the loaded event for the control as:

      foreach (var seriesMapping in tradeHistoryChart.SeriesMappings) 
            { 
                foreach (var itemMapping in seriesMapping.ItemMappings) 
                { 
                    switch (itemMapping.FieldName) 
                    { 
                        case "Value": 
                            itemMapping.FieldType = Type.GetType("System.Double"); 
                            break; 
                        case "Key": 
                            itemMapping.FieldType = Type.GetType("System.DateTime"); 
                            break; 
                    } 
                } 
            } 

and it didn't help, this wasn't a problem in the previous release.

Any help is appreciated.

Thanks,
Vic
0
Ves
Telerik team
answered on 26 Mar 2010, 03:52 PM
Hi everyone,

Our developers improved the behavior in case of databinding to empty source, so you should not experience such issues anymore. The fix will be available in the latest internal build later today.

Vic,  please, give this LIB a try and if the issue remains - send us small example, attached to support ticket, so we can review it. Thanks.

Best regards,
Ves
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jani
Top achievements
Rank 1
answered on 29 Mar 2010, 08:04 AM
Hi Ves,

Issue is still present in latest internal build 2010_1_0326:
Error: Unhandled Error in Silverlight Application  
Code: 4004     
Category: ManagedRuntimeError        
Message: System.NullReferenceException: Object reference not set to an instance of an object. 
   at Telerik.Windows.Controls.Charting.DataBindingHelper.AssignMappingFieldTypes(QueryableCollectionView dataEngine, SeriesMapping seriesMapping) 
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessNoGrouping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState, Int32 seriesCount) 
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMapping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState, Int32 seriesCount) 
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMappings(SeriesMappingCollection seriesMappings, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState) 
   at Telerik.Windows.Controls.Charting.DataBindingHelper.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ISeriesDefinition defaultSeriesDefinition, ChartFilterDescriptorCollection globalFilterDescriptors, ChartSortDescriptorCollection globalSortDescriptors, SamplingSettings samplingSettings, ZoomScrollSettings zoomScrollSettings, AxisRangeState axisXRangeState) 
   at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ChartArea chartArea) 
   at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData) 
   at Telerik.Windows.Controls.RadChart.Rebind(Object originalData) 
   at Telerik.Windows.Controls.RadChart.Rebind() 
   at Telerik.Windows.Controls.RadChart.InternalRebind() 
   at Telerik.Windows.Controls.RadChart.OnApplyTemplate() 
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)    

Cheers,
Jani


0
Vic
Top achievements
Rank 2
answered on 29 Mar 2010, 02:04 PM
Hi Ves,

The internal build 2010.1.319.1030 corrects the issue, thanks.

Though what is the timeframe for the next release?

Thanks,
Vic
0
Accepted
Ves
Telerik team
answered on 31 Mar 2010, 11:10 AM
Hi,

Jani, the chart works correctly for me. Please, make sure you have upgraded correctly.

Vic, the official service pack is expected in mid-April.

Best regards,
Ves
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jani
Top achievements
Rank 1
answered on 01 Apr 2010, 08:22 AM
Hi Ves,

Thanks for your Feedback.

I have found the reason for my problem. My chart contains an item mapping (DataPointMember=LegendLabel) to a class property which returns a string. Initially the value of this property is null. After loading the chart data asynchronously, the property value contains a string.

Initializing the property value to an empty string, seems to be a reasonable workaround.

Thanks again for your support.

Cheers,
Jani
0
Sunil
Top achievements
Rank 2
answered on 28 Oct 2010, 04:16 PM
need help

{System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.Charting.DataBindingHelper.AssignMappingFieldTypes(QueryableCollectionView dataEngine, SeriesMapping seriesMapping)
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessNoGrouping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState, Int32 seriesCount)
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMapping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState, Int32 seriesCount)
   at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMappings(SeriesMappingCollection seriesMappings, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState)
   at Telerik.Windows.Controls.Charting.DataBindingHelper.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ISeriesDefinition defaultSeriesDefinition, ChartFilterDescriptorCollection globalFilterDescriptors, ChartSortDescriptorCollection globalSortDescriptors, SamplingSettings samplingSettings, ZoomScrollSettings zoomScrollSettings, AxisRangeState axisXRangeState)
   at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ChartArea chartArea)
   at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData)
   at Telerik.Windows.Controls.RadChart.Rebind(Object originalData)
   at Telerik.Windows.Controls.RadChart.ItemsSourcePropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
   at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
   at System.Windows.Data.BindingExpression.SendDataToTarget()
   at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
   at System.Windows.PropertyPathListener.RaisePropertyPathStepChanged(PropertyPathStep source)
   at System.Windows.PropertyAccessPathStep.RaisePropertyPathStepChanged(PropertyListener source)
   at System.Windows.CLRPropertyListener.SourcePropertyChanged(Object sender, PropertyChangedEventArgs args)
   at System.Windows.Data.WeakPropertyChangedListener.PropertyChangedCallback(Object sender, PropertyChangedEventArgs args)
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at iFIS.ViewModel.ViewModelBase.NotifyPropertyChanged(String propertyName)
   at iFIS.ViewModel.CostDashboardViewModel.set_AssetDashboard(ObservableCollection`1 value)
   at iFIS.ViewModel.CostDashboardViewModel.<>c__DisplayClass4.<clientProxy_GetDataCompleted>b__2()}
Tags
Chart
Asked by
Jani
Top achievements
Rank 1
Answers by
Ves
Telerik team
Jani
Top achievements
Rank 1
Vic
Top achievements
Rank 2
Sunil
Top achievements
Rank 2
Share this question
or