我正在使用在 .NET 3.5 上运行的 TeeChart Pocket。目标应用程序正在运行带有 .NET 3.5 的 Windows CE 6.0。我制作了一个绘制饼图的小型表单应用程序,但是当我添加边缘样式时,我得到了一个NullReferenceException
.
产生此异常的最小代码(无设计器代码)如下所示:
public class Form1 : Form
{
public Form1()
{
InitializeComponent();
var series = new Pie();
series.FillSampleValues(6);
series.BevelPercent = 20;
series.EdgeStyle = EdgeStyles.Curved;
var chart = new TChart();
chart.Series.Add(series);
this.Controls.Add(chart);
}
}
以下程序也会引发此异常:
chart.Series.Add(series);
series.FillSampleValues(6);
series.BevelPercent = 20;
series.EdgeStyle = EdgeStyles.Curved;
chart.Location = new Point(0, 0);
chart.Width = this.Width;
chart.Height = this.Height;
this.Controls.Add(chart);
为什么我得到一个NullReferenceException
?如果我取消注释设置 的行EdgeStyle
,则不会引发异常。这是完整的堆栈跟踪:
System.NullReferenceException was unhandled
Message="NullReferenceException"
StackTrace:
at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Polygon(PointDouble[] p)
at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DrawPoints()
at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DoTopGradient(Int32 zDepth)
at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DoCurvedGradient(Int32 zDepth)
at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DrawLighting(EdgeStyles edgeStyle)
at Steema.TeeChart.Drawing.Graphics3D.Pie3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
at Steema.TeeChart.Drawing.Graphics3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
at Steema.TeeChart.Drawing.Graphics3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xOffset, Int32 yOffset, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
at Steema.TeeChart.Styles.Pie.DrawPie(Graphics3D g, Int32 valueIndex)
at Steema.TeeChart.Styles.Pie.DrawPie(Int32 valueIndex)
at Steema.TeeChart.Styles.Pie.DrawValue(Int32 valueIndex)
at Steema.TeeChart.Styles.Pie.Draw()
at Steema.TeeChart.Styles.Series.DrawSeries()
at Steema.TeeChart.Chart.DrawAllSeries(Graphics3D g)
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
at Steema.TeeChart.Chart.InternalDraw(Graphics g)
at Steema.TeeChart.Pocket.TChart.Draw(Graphics g)
at Steema.TeeChart.Pocket.TChart.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.WL.Update(IntPtr hwnThis)
at System.Windows.Forms.Control.Update()
at System.Windows.Forms.Control.Refresh()
at Steema.TeeChart.Pocket.TChart.OnResize(EventArgs e)
at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
at System.Windows.Forms.Application.Run(Form fm)
at Demo.Form1.Main()
InnerException: