Unhandled exception
Posted: Fri Mar 07, 2008 4:08 pm
I ran into a case where the TeeChart control was throwing an exception and it was not getting handled.
This exception was causing my application to crash and until I looked into my Windows Event Viewer under Application Logs I could not figure out what was causing the problem.
Because we have the source code I was able to load up the TeeChart for .NET V3 source and find the offending line of code.
I am not clear how to reproduce the exception in a simple example, but below is what I found
When inspecting the Call to CanvasGDIplus.public override void Ellipse(int x1, int y1, int x2, int y2) , the following was passed in
x1 = 2147483646
y1 = 2147483646
x2 = -2147483646
y2 = -2147483646
To fix the unhandled exception I added a catch block to the try block within Steema.TeeChart.TChart.Draw(Graphics g) method. The catch block does nothing, but it does prevent an unhandled exception. I would like someone to comment on my solution.
The details of the exception found in the Application Event Viewer were:
Event Type: Information
Event Source: TCCUnhandledException
Event Category: None
Event ID: 0
Date: 3/7/2008
Time: 1:20:55 AM
User: N/A
Computer: TCCJONES
Description:
General Exception in Application with the following information:
Overflow error.
Stack Trace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillEllipse(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.FillEllipse(Brush brush, Rectangle rect)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Ellipse(Int32 x1, Int32 y1, Int32 x2, Int32 y2) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Drawing\CanvasGDIplus.cs:line 760
at Steema.TeeChart.Styles.SeriesPointer.Draw(Graphics3D g, Boolean is3D, Int32 px, Int32 py, Int32 tmpHoriz, Int32 tmpVert, Color colorValue, PointerStyles aStyle) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 650
at Steema.TeeChart.Styles.SeriesPointer.Draw(Int32 px, Int32 py, Color colorValue, PointerStyles aStyle) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 730
at Steema.TeeChart.Styles.CustomPoint.DrawPointer(Int32 aX, Int32 aY, Color aColor, Int32 valueIndex) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 1215
at Steema.TeeChart.Styles.CustomPoint.DrawValue(Int32 valueIndex) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 1345
at Steema.TeeChart.Styles.Series.Draw() in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Series.cs:line 3055
at Steema.TeeChart.Styles.Series.DrawSeries() in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Series.cs:line 3131
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Chart.cs:line 803
at Steema.TeeChart.Chart.InternalDraw(Graphics g) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Chart.cs:line 685
at Steema.TeeChart.TChart.Draw(Graphics g) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\TeeChart.cs:line 565
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\TeeChart.cs:line 605
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TCPSM.Program.Main() in C:\TCC\Development\Client\Source\TCPSM2\Program.cs:line 119
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
This exception was causing my application to crash and until I looked into my Windows Event Viewer under Application Logs I could not figure out what was causing the problem.
Because we have the source code I was able to load up the TeeChart for .NET V3 source and find the offending line of code.
I am not clear how to reproduce the exception in a simple example, but below is what I found
When inspecting the Call to CanvasGDIplus.public override void Ellipse(int x1, int y1, int x2, int y2) , the following was passed in
x1 = 2147483646
y1 = 2147483646
x2 = -2147483646
y2 = -2147483646
Code: Select all
public override void Ellipse(int x1, int y1, int x2, int y2)
{
Rectangle r=new System.Drawing.Rectangle(x1,y1,x2-x1,y2-y1);
if (Brush.visible)
if (Brush.GradientVisible)
g.FillEllipse(Brush.Gradient.DrawingBrush(r),r);
else
g.FillEllipse(Brush.DrawingBrush,r); <- Exception "Overflow Error"
if (Pen.bVisible)
g.DrawEllipse(Pen.DrawingPen,r);
}
The details of the exception found in the Application Event Viewer were:
Event Type: Information
Event Source: TCCUnhandledException
Event Category: None
Event ID: 0
Date: 3/7/2008
Time: 1:20:55 AM
User: N/A
Computer: TCCJONES
Description:
General Exception in Application with the following information:
Overflow error.
Stack Trace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillEllipse(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.FillEllipse(Brush brush, Rectangle rect)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Ellipse(Int32 x1, Int32 y1, Int32 x2, Int32 y2) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Drawing\CanvasGDIplus.cs:line 760
at Steema.TeeChart.Styles.SeriesPointer.Draw(Graphics3D g, Boolean is3D, Int32 px, Int32 py, Int32 tmpHoriz, Int32 tmpVert, Color colorValue, PointerStyles aStyle) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 650
at Steema.TeeChart.Styles.SeriesPointer.Draw(Int32 px, Int32 py, Color colorValue, PointerStyles aStyle) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 730
at Steema.TeeChart.Styles.CustomPoint.DrawPointer(Int32 aX, Int32 aY, Color aColor, Int32 valueIndex) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 1215
at Steema.TeeChart.Styles.CustomPoint.DrawValue(Int32 valueIndex) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Styles\Custom.cs:line 1345
at Steema.TeeChart.Styles.Series.Draw() in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Series.cs:line 3055
at Steema.TeeChart.Styles.Series.DrawSeries() in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Series.cs:line 3131
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Chart.cs:line 803
at Steema.TeeChart.Chart.InternalDraw(Graphics g) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\Chart.cs:line 685
at Steema.TeeChart.TChart.Draw(Graphics g) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\TeeChart.cs:line 565
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe) in C:\TCC\Development\3rd Party\Source\TeeChartNetV3\Sources\TeeChart\TeeChart.cs:line 605
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TCPSM.Program.Main() in C:\TCC\Development\Client\Source\TCPSM2\Program.cs:line 119
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Code: Select all