08-14-2025 10:58 AM
Hello,
I have been getting this error for several years now, and I need to address it as it may be causing other problems in my application. I have several XY charts in my application and I am plotting to each of them at 1 Hz. Most of the time all is well. Sometimes, possible when I have performance issues with the PC, I get a bunch of errors on the PlotYAppendMultiple call. The following is the exception trace:
07:55:05 DisplayData - Chart Error on Chart 6 waveform .
System.ArgumentException: Item has already been added. Key in dictionary: '191' Key being added: '191'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at NationalInstruments.UI.Internal.ScaleElement.AddValueToHashtable(Double tickValue, Double deviceTickValue, DivisionBase division, Graphics graphics, Boolean isEndLabel)
at NationalInstruments.UI.Internal.LinearTickGridInfoPopulator.a(Graphics A_0, ScaleElement A_1, Double A_2, Double A_3, Double A_4, Divisions A_5)
at NationalInstruments.UI.Internal.LinearTickGridInfoPopulator.CalculateMajorTicks(Graphics graphics, ScaleElement scaleElement, Double majorTickValue, Double majorDivisionInterval, Double tolerance, Divisions majorDivisions)
at NationalInstruments.UI.Internal.LinearTickGridInfoPopulator.NonLogDivisionMajorVisibleMinorNotVisibleMajorGridNotVisibleMinorGridNotVisible(Graphics graphics, ScaleElement scaleElement, Int32 numberOfMajorTicks, Double majorTickValue, Double minorTickValue, Double majorDivisionInterval, Double minorDivisionInterval, Double tolerance, Divisions majorDivisions, Divisions minorDivisions)
at NationalInstruments.UI.Internal.ScaleElement.CalculateLinearDivisionData(Graphics graphics, Double majorDivisionInterval, Double minorDivisionInterval)
at NationalInstruments.UI.Internal.AxisElement.CalculateDivisionData(LayoutArgs layoutArgs, Boolean isLayingOut)
at NationalInstruments.UI.Internal.XInnerAxisElement.Layout(LayoutArgs layoutArgs)
at NationalInstruments.Restricted.XYGraphManager.OnXAxisDivisionsChanged(Object sender, ControlElementEventArgs e)
at NationalInstruments.Restricted.ControlElementEventHandler.Invoke(Object sender, ControlElementEventArgs e)
at NationalInstruments.UI.Internal.ScaleElement.OnDivisionsChanged(Object sender, ControlElementEventArgs e)
at NationalInstruments.UI.Internal.ScaleElement.OnDivisionsChanged()
at NationalInstruments.UI.Internal.ScaleElement.set_Range(Range value)
at NationalInstruments.Restricted.XYGraphManager.ScaleAxes(CartesianPlotElement sourcePlot)
at NationalInstruments.Restricted.XYGraphManager.ScaleAxesOnPlotDataChanged(Object sender, ControlElementEventArgs e)
at NationalInstruments.Restricted.ControlElementEventHandler.Invoke(Object sender, ControlElementEventArgs e)
at NationalInstruments.UI.Internal.PlotElement.OnDataChanged(ControlElementEventArgs e)
at NationalInstruments.UI.Internal.CartesianPlotElement.a(Object A_0, PlotDataChangedEventArgs A_1)
at NationalInstruments.UI.Internal.PlotDataChangedEventHandler.Invoke(Object sender, PlotDataChangedEventArgs e)
at NationalInstruments.UI.Internal.XYDataManager.a(PlotDataChangedEventArgs A_0)
at NationalInstruments.UI.Internal.XYDataManager.CopyYData[TStart,TIncrement](Double[] yData, Int32 startIndex, Int32 length, TStart start, TIncrement increment, Boolean append)
at NationalInstruments.UI.Internal.WaveformPlotElement.PlotYAppend(Double[] yData, Int32 startIndex, Int32 length, Double increment)
at NationalInstruments.UI.Internal.WaveformPlotElement.PlotYAppend(Double[] yData)
at NationalInstruments.Restricted.WaveformGraphManager.PlotYAppendMultiple(Double[,] yData, DataOrientation orientation)
at NationalInstruments.UI.WindowsForms.WaveformGraph.PlotYAppendMultiple(Double[,] yData)
at DEER_DAQ.modFunctions.DisplayData()
This is my call:
frmD.WaveformGraph(cnt).PlotYAppendMultiple(ChartData)
This is how ChartData is declared:
Public ChartData(10, 0) As Double
This is a multi-threaded application, so it may be possible that I am entering into this function before the last iteration was completed. I have set up a flag so that if I have not completed this function, future calls will bounce out now. The function is not critical as it is just a display to the screen. Any other ideas on why I would get a barrage of these errors at one moment in time?