Page 1 of 1

Problems with an unmanaged DLL

Posted: Wed Jul 05, 2006 2:25 pm
by 8128974
Here is a description of the problem:

I placed a tchart NET control on a form and did not change any of the default properties (no series added at all).

When I start a connection with an industrial acquisition device (that has a software support in the form of an unmanaged DLL that manages a FIFO data structure) in the same thread (the application has only one thread) at the first repaint of the tchart (i.e. when moving the mouse cursor over it) I get this exception:

Overflow or underflow during arithmetic operation.
at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font.Initialize(String familyName, Single emSize, FontStyle style, GraphicsUnit unit)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style)
at Steema.TeeChart.Drawing.ChartFont.get_DrawingFont()
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureString(ChartFont f, String text)
at Steema.TeeChart.Drawing.Graphics3D.TextHeight(String text)
at Steema.TeeChart.Drawing.Graphics3D.get_FontHeight()
at Steema.TeeChart.Title.Draw(Graphics3D g, Rectangle& rect)
at Steema.TeeChart.Title.DoDraw(Graphics3D g, Rectangle& rect, Boolean CustomOnly)
at Steema.TeeChart.Chart.DrawTitleFoot(Rectangle& rect, Boolean CustomOnly)
at Steema.TeeChart.Chart.DrawTitlesAndLegend(Graphics g, Rectangle& tmp, Boolean BeforeSeries)
at Steema.TeeChart.Chart.InternalDraw(Graphics g)
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
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.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.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.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMess Il programma "[3476] Prototype.exe" è terminato con il codice 0 (0x0).
ageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Prototype.Main.main() in C:\sviluppo\Working\Studio\Prototype\Prototype\Main.vb:line 5


I think that the unmanaged DLL provided with the acquisition device uses memory in a way that confilcts with the tchart.

Do someone has any suggestion to fix this problem?

Is it possible to create a derived class of tChart redefining the paint event handler in order to trap this error (leaving any other property/method unthouched)? If so, can you give me an example that does this in vb.NET (which class and method do I have to inherit from and to override)?

Thanks to everyone for your help

Posted: Thu Jul 06, 2006 10:32 am
by narcis
Hi gdc,

You could try disabling all strings in TeeChart (headers, footers, axis titles, axis labels, no legend, etc.) to see if the problem is exclusive to fonts or not. Also, could you please let us know which TeeChart version are you using?

Thanks in advance.

Posted: Thu Jul 06, 2006 11:52 am
by 8128974
The tchart version is 1.1.2307.20497

I tried to do like you suggest (any kind of string is invisible): what I have got is that I don't get a crash when the chart is completely empty but when I try to draw on the tchart (I defined 1 series)


'*** teechart definition code in the form (initializeComponent method)
'TChart1
'
'
'TChart1.Aspect
'
Me.TChart1.Aspect.View3D = False
'
'TChart1.Axes
'
Me.TChart1.Axes.Visible = False
Me.TChart1.Cursor = System.Windows.Forms.Cursors.Default
'
'TChart1.Header
'
Me.TChart1.Header.Lines = New String() {"TeeChart"}
Me.TChart1.Header.Visible = False
'
'TChart1.Legend
'
Me.TChart1.Legend.Visible = False
Me.TChart1.Location = New System.Drawing.Point(504, 360)
Me.TChart1.Name = "TChart1"
Me.TChart1.Series.Add(Me.Line1)
Me.TChart1.Size = New System.Drawing.Size(120, 88)
Me.TChart1.TabIndex = 16
'
'TChart1.Walls
'
Me.TChart1.Walls.Visible = False
'
'Line1
'
'
'Line1.Brush
'
Me.Line1.Brush.Color = System.Drawing.Color.Red
'
'Line1.Pointer
'
'
'Line1.Pointer.Brush
'
Me.Line1.Pointer.Brush.Color = System.Drawing.Color.Red
Me.Line1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle
Me.Line1.Title = "line1"
'
'Line1.XValues
'
Me.Line1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending


'***

'**** code that adds some points
Dim i As Integer
For i = 0 To 1000
Me.TChart1.Series(0).Add(CDbl(i), Math.Sin(CDbl(i) * 6.28 / 200))
Next


When I perform the code that adds the points here is the exception that raises


Overflow o underflow durante un'operazione aritmetica.
at System.Double.IsNaN(Double d)
at System.Double.Equals(Object obj)
at Steema.TeeChart.Axis.CalcYPosValue(Double value)
at Steema.TeeChart.Styles.Series.CalcYPosValue(Double value)
at Steema.TeeChart.Styles.Series.CalcYPos(Int32 index)
at Steema.TeeChart.Styles.CustomPoint.CalcYPos(Int32 valueIndex)
at Steema.TeeChart.Styles.Custom.DrawValue(Int32 valueIndex)
at Steema.TeeChart.Styles.Series.Draw()
at Steema.TeeChart.Styles.Custom.Draw()
at Steema.TeeChart.Styles.Series.DrawSeries()
at Steema.TeeChart.Chart.InternalDraw(Graphics g)
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
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.ControlNativeWindow.OnMeIl programma "[5288] Prototype.exe" è terminato con il codice 0 (0x0).
ssage(Message& m)
at System.Windows.Forms.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.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Prototype.Main.main() in C:\sviluppo\Working\Studio\Prototype\Prototype\Main.vb:line 5



What can I do?

Posted: Thu Jul 06, 2006 3:32 pm
by Chris
Hello,

Do you get the same if you use:

Me.TChart1.Series(0).FillSampleValues() ?

What happens when you take TeeChart out of your code and try and use

System.Double.IsNaN() ?