Hi,
I'm trying to use ComponentPro Word to edit charts embedded in the document. When I call the chart.ChartData.SetChartData() method I get a NullReferenceException in the file ChartImpl.cs. Specifically, this line in the ComponentPro code throws the exception...line 3760 in ChartImpl.cs
if (parentChart.Categories.Count > i)
{
(parentChart.Categories[i] as ChartCategory).CategoryLabelIRange = range2; <===== Exception Thrown here
(parentChart.Categories[i] as ChartCategory).ValuesIRange = categoryRange;
if ((parentChart.Categories[0].CategoryLabel as ChartDataRange).Range != null)
{
(parentChart.Categories[i] as ChartCategory).Name = (parentChart.Categories[0].CategoryLabel as ChartDataRange).Range.Cells[i].Text;
}
}
The null reference is being returned by parent.Categories[i]. When looking at the code in ChartCategroyCollection.cs it has the following...
public new ChartCategory this[int index]
{
get
{
return null; <=== This is why we are getting a null
}
set
{
throw new NotSupportedException();
}
}
I have changed the source code to try and fix this, and it appears to work.
public new ChartCategory this[int index]
{
get
{
return base[index]; <=== This line is modified
}
set
{
throw new NotSupportedException();
}
}
But I'm not sure if this is the correct way to fix this. I believe I am running the latest version of UltimateStudio-Pro v7.1.233.49, and it includes the source code.
Can someone please update your source code and release a new version of the product soon.
Thanks
asked 9/14/2021 2:23:58 AM