Jump to content
Software FX Community

Exception when drawing chart


jbloomer

Recommended Posts

I get the following exception when drawing a chart. The exception is intermittent and I can't tie down what cause it.I've just installed the 6.2.3188.26800 SP but it makes no difference. The OS is Vista SP1.

 

************** Exception Text **************

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.

at SoftwareFX.ChartFX.Annotation.AnnotationList.0O(IGraphicsEx AQ, Rectangle AR, Boolean AS, Boolean AT, Int32 AU, Int32 AV)

at SoftwareFX.ChartFX.Annotation.AnnotationX.24(IGraphicsEx F3, Rectangle F4, Boolean F5, Int32 F6, Int32 F7)

--- End of inner exception stack trace ---

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

at SoftwareFX.ChartFX.ExtensionManager.MI(19 2CA, Enum 2CB, Object[] 2CC)

at SoftwareFX.ChartFX.ChartCore.EP(1R 1T1, Boolean 1T2, Boolean 1T3)

at SoftwareFX.ChartFX.ChartCore.EO(1R 1SY, Rectangle& 1SZ, Int32& 1T0)

at SoftwareFX.ChartFX.ChartCore.EN(PaintBar 1SV, IGraphicsEx 1SW, Rectangle& 1SX)

at SoftwareFX.ChartFX.0X.OnPaint(PaintEventArgs e)

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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

Relevant Loaded Assemblies:

 mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3074 (QFE.050727-3000) CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

----------------------------------------

System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll ---------------------------------------- System.Configuration Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3074 (QFE.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- System.Runtime.Remoting Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll ---------------------------------------- Infragistics.Win.UltraWinToolbars.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Win.UltraWinToolbars.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Win.UltraWinToolbars.v5.3.dll ---------------------------------------- Infragistics.Shared.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Shared.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Shared.v5.3.dll ---------------------------------------- Infragistics.Win.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Win.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Win.v5.3.dll ---------------------------------------- Accessibility Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll ---------------------------------------- System.Design Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll ---------------------------------------- System.Data Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- Infragistics.Win.UltraWinExplorerBar.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Win.UltraWinExplorerBar.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Win.UltraWinExplorerBar.v5.3.dll ---------------------------------------- Infragistics.Win.UltraWinGrid.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Win.UltraWinGrid.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Win.UltraWinGrid.v5.3.dll ---------------------------------------- Infragistics.Win.UltraWinTabControl.v5.3 Assembly Version: 5.3.20053.50 Win32 Version: 5.3.20053.50 CodeBase: file:///C:/Windows/assembly/GAC/Infragistics.Win.UltraWinTabControl.v5.3/5.3.20053.50__7dd5c3163f2cd0cb/Infragistics.Win.UltraWinTabControl.v5.3.dll ---------------------------------------- ChartFX Assembly Version: 6.2.1342.0 Win32 Version: 6.2.1342.0 CodeBase: file:///C:/C2CTools/localhost/C2C%20Tools%20Client/updates/ChartFX.DLL ---------------------------------------- ChartFX.Base Assembly Version: 6.2.1342.0 Win32 Version: 6.2.1342.0 CodeBase: file:///C:/C2CTools/localhost/C2C%20Tools%20Client/updates/ChartFX.Base.DLL ---------------------------------------- ChartFX.Annotation Assembly Version: 6.2.1342.0 Win32 Version: 6.2.1342.0 CodeBase: file:///C:/C2CTools/localhost/C2C%20Tools%20Client/updates/ChartFX.Annotation.DLL

Link to comment
Share on other sites

  • 2 months later...

Hi,

Can you please provide a code snippet that replicates the issue? The Object reference not set to an instance of an object message is not  very straight forward message. By the error log, I can see that there is something  happening with the annotation list, but I'll appreciate if you can provide us the way you are handling the code in order to help you better.

Juan.

Link to comment
Share on other sites

 Hi Juan,

Thanks for the quick reply.  Here is the code...

  • Sub Routine That draws the chart
  Public Sub DrawCharts(ByVal uDate As String)
  If mLocked Then Return
  Try

  GetAdditionInfo()
  poly = Nothing
  CurrentDate = uDate
  UserPointSerie = CInt(IIf(UserPoints.Count > 0, 1, 0))
  'Chart.ClearData(
ClearDataFlag.AllData)

  Chart.Extensions.Clear()
  ClearChartStuff()
  'ClearChart()
  Try
  Dim obj As Object = CType(Graph.Axis(1), snAxis).curves(0)
  Catch tEx As Exception

  MsgBox(tEx.ToString())
  Exit Sub
  End Try

  '  Chart.Style = ChartStyle.All

  Chart.DataEditor = IIf(mWorkNormalize, False, Graph.DataEditor)

  Chart.ShowTips = True
  Chart.Highlight.Enabled = bHighlight
  Chart.ToolBar = False
  Chart.Gallery = Gallery.Lines

  SetAttributes()
  PassData()


  Set3DView()

  '   SetAttributes()

  DrawBorder()
  DrawBackground()
  DrawBorder()
  DrawTitles()
  DrawLegend()

  DrawGridLines()
  DrawAnnotations()
  DrawLines()
  DrawStripes()
  DrawTrendPoints()
  DrawDynamicAnnotations()

  Catch ex As Exception

  Console.WriteLine("Epa: " & ex.Message)
  End Try
  UpdateToolbar()
  End Sub



  • Sub Routine to clear chart. 
    Public Sub ClearChartStuff()
      Chart.ClearData(ClearDataFlag.Data)

      'Chart.ClearData(ClearDataFlag.Extensions)
      Chart.ClearData(ClearDataFlag.IniValues)
      Chart.ClearData(ClearDataFlag.Stripes)
      Chart.ClearData(ClearDataFlag.XValues)
      Chart.ClearData(ClearDataFlag.Values)

      'Chart.ClearData(ClearDataFlag.ConstantLines)
      Chart.ClearData(ClearDataFlag.Labels)
      'Chart.ClearData(ClearDataFlag.ColorsAndPatterns)
      'Chart.ClearData(ClearDataFlag.Commands)

      Chart.ClearData(ClearDataFlag.Other)
      Chart.ClearData(ClearDataFlag.Strings)
      Chart.ClearData(ClearDataFlag.Titles)
      End Sub


  • Following Sub Routine draws the Annotations...
 Public Sub DrawAnnotations()
  Try

  If Not (Graph.AnnotationsShow Or Graph.StickyNoteShow) Then
  Exit Sub
  End If
  Dim i As Integer
  '#If _cfx70 Then

  'Dim annotations As Annotations = New Annotations
  '#Else
  Dim annotations As AnnotationX = New AnnotationX
  '#End If
  Dim balloon As AnnotationBalloon

  Dim note As snStickyNote
  Dim anno As snAnnotation
  Dim text As String
  Dim x1, x2 As Double


  'poly = New AnnotationPolygon

  '' this hold the polygon to draw Lines and Rects when zooming


  'jnaPts = New ArrayList
  'poly.Border.Color = Color.Black
  'poly.Border.Style = Drawing2D.DashStyle.Dash
  'poly.Border.Width = 0


  'annotations.List.Add(poly)



  If Graph.StickyNoteShow Then
  For i = 0 To Graph.StickyNotes.Count - 1
  Try
  note = Graph.StickyNotes(i)
  If note.Text <> "" Then

  text = note.Text
  text = ReplaceText(text)
  balloon = New AnnotationBalloon
  balloon.Text = text
  balloon.Shadow = 3

  note.balloon = balloon
  If note.ValueOption.StartsWith("P") Then
  balloon.Left = CInt(note.x)
  balloon.Top = CInt(note.y)

  Else
  Dim x As Double
  If bIsDate Then
  x = jnaUtil.DateFns.StringToDate(note.x).ToOADate

  Else
  x = jnaUtil.StringFns.Number(note.x, 0.0)
  End If
  balloon.Attach(x, jnaUtil.StringFns.Number(note.y, 0.0))

  End If

  balloon.TextColor = plotStuff.GetColor(note.TextColor)
  balloon.TailCorner = CInt(plotStuff.TailPosition(note.TailPosition))

#If Not _cfx70 Then
  balloon.ArrowFactor = CInt(plotStuff.TailSize(note.TailSize))
#End If
  balloon.Border.Color = System.Drawing.Color.Black
  balloon.Color = plotStuff.GetColor(note.BGColor)


  balloon.SizeToFit()
  annotations.List.Add(balloon)
  End If
  Catch e As Exception
  MsgBox("jna 111 " & e.Message)

  End Try
  Next i
  End If


  Dim label As AnnotationText

  If Graph.AnnotationsShow Then
  Dim bWidth As Boolean



  For i = 0 To Graph.Annotations.Count - 1
  anno = CType(Graph.Annotations(i), snAnnotation)
  Try
  If anno.Text.StartsWith("OVS:") And anno.X1.StartsWith("OVS:") And anno.Y1.StartsWith("OVS:") Then

  Dim n, j As Integer
  Dim dt As DataTable
  Dim dc As New DataCenter.DataCenter.clsDC
  Dim vText, vXValue, vYValue As String

  Dim xx, yy, ttext As Object

  vText = anno.Text.Substring(4)
  vXValue = anno.X1.Substring(4)
  vYValue = anno.Y1.Substring(4)

  dt = dc.SelectData("", vText, vXValue, vYValue)
  n = dt.Rows.Count
  If n > 0 Then
  For j = 0 To n - 1

  Try
  label = New AnnotationText
  anno.label = label
  xx = dc.GetValue(dt, vXValue, j, Now)

  yy = dc.GetValue(dt, vYValue, j, 0.0)
  ttext = dc.GetValue(dt, vText, j, "")

  label.Text = ttext

  label.TextColor = plotStuff.GetColor(anno.Color)
  label.Color = System.Drawing.Color.Transparent
  label.Border.Color = System.Drawing.Color.Transparent

  label.Orientation = plotStuff.AnnoOrientation(anno.Orientation)
  label.Align = StringAlignment.Near
  label.WordWrap = anno.WordWrap

  If bIsDate Then
  x1 = jnaUtil.DateFns.StringToDate(xx).ToOADate
  Else
  x1 = xx

  End If

  label.SizeToFit()

  label.Attach(x1, yy)

  annotations.List.Add(label)

  Catch
  End Try
  Next
  End If
  Else

  label = New AnnotationText

  anno.label = label
  label.Text = ReplaceText(anno.Text)
  label.TextColor = plotStuff.GetColor(anno.Color)
  label.Color = System.Drawing.Color.Transparent

  label.Border.Color = System.Drawing.Color.Transparent
  label.Orientation = CInt(plotStuff.AnnoOrientation(anno.Orientation))
  label.WordWrap = anno.WordWrap


  bWidth = True

  If anno.x2 = "" Then
  label.Width = 200
  label.Height = 100

  bWidth = False
  End If

  If anno.ValueOption.StartsWith("P") Then
  label.Left = jnaUtil.StringFns.Number(anno.X1, 0)

  label.Top = jnaUtil.StringFns.Number(anno.Y1, 0)
  If bWidth Then
  label.Width = jnaUtil.StringFns.Number(anno.x2, 0)

  label.Height = jnaUtil.StringFns.Number(anno.Y2, 0)
  End If
  Else
  If bIsDate Then
  x1 = jnaUtil.DateFns.StringToDate(anno.X1).ToOADate

  If bWidth Then x2 = jnaUtil.DateFns.StringToDate(anno.x2).ToOADate
  Else
  x1 = anno.X1
  x2 = anno.x2

  End If
  If bWidth Then
  label.Attach(x1, jnaUtil.StringFns.Number(anno.Y1, 0.0), x2, jnaUtil.StringFns.Number(anno.Y2, 0.0))

  Else
  label.Attach(x1, jnaUtil.StringFns.Number(anno.Y1, 0.0))
  End If
  End If
  label.SizeToFit()

  annotations.List.Add(label)
  End If
  Catch e As Exception
  MsgBox("show ")
  End Try

  Next
  End If

  mUserAnnotations = annotations.List.Count

  'The following might not be necessary after we upgrade to Chart FX 6.2 version 6.2.3188.*
  ' looking to fix vista

  If mUserAnnotations > 0 Then
  Chart.Extensions.Add(annotations)
  End If
  Catch ex As Exception
  MsgBox(ex.ToString())
  End Try
  End Sub
-
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...