我有好多带有MSChart控件的UserControl(C# WinForm),打包成DLL后在Delphi中调用,MSChart没任何点击事件处理,在Delphi中调用时,有时点击MSChart图形会报溢出错误(在.net环境下不会报),错误提示如下:See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************
System.ArithmeticException: Overflow or underflow in the arithmetic operation.
   at System.Windows.Forms.DataVisualization.Charting.AxisScaleView.get_ViewMaximum()
   at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultFromIndexes(Axis axis)
   at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultFromIndexesOrData(Axis axis, AxisType axisType)
   at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultAxesValues()
   at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetData(Boolean initializeAxes, Boolean checkIndexedAligned)
   at System.Windows.Forms.DataVisualization.Charting.ChartArea.ReCalcInternal()
   at System.Windows.Forms.DataVisualization.Charting.ChartPicture.Paint(Graphics graph, Boolean paintTopLevelElementOnly)
   at System.Windows.Forms.DataVisualization.Charting.ChartPicture.PaintOffScreen()
   at System.Windows.Forms.DataVisualization.Charting.Selection.HitTest(Int32 x, Int32 y, Boolean ignoreTransparent, ChartElementType[] requestedElementTypes)
   at System.Windows.Forms.DataVisualization.Charting.Selection.HitTest(Int32 x, Int32 y)
   at System.Windows.Forms.DataVisualization.Charting.Chart.HitTest(Int32 x, Int32 y)
   at BaseControls.NewChart.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************不知有没有人遇到过这样的问题?求高人解答

解决方案 »

  1.   

    这个错误看不出来时溢出错误啊。
    一般出现溢出错误,是因为DLL需要调用方释放内存, 如释放字符串类型的内存,最后卸载DLL
    不知道这些你做没?有些情况下,释放了还出现错误,是因为字符串的大小不符合。
      

  2.   

    感谢楼上的回答,DLL调用内存释放都做过处理。
    这个问题暂时解决了,没找到问题的根源。我解决的方法是重写了OnMouseDown OnMouseClick OnMouseUp方法,不做任何操作