Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

System.ArgumentException occurred when disposing IntrumentControlStrip objects

Hi Guys,
 
Though this is not a major issues, this had annoyed me for a while. I had an error with the designer when closing some forms. See image attached.
 
Then, while debugging, I saw some strange System.ArgumentException in the ouput.
 
 
Here's the error:
 
System.ArgumentException occurred
  Message="Impossible to convert objet type 'System.EventHandler' to type 'System.ComponentModel.CollectionChangeEventHandler'."
  Source="mscorlib"
  StackTrace:
       à System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
 
And here's the call stack:
 
  mscorlib.dll!System.RuntimeType.CheckValue(object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) + 0x313 bytes 
  mscorlib.dll!System.Reflection.MethodBase.CheckArguments(object[] parameters = {Dimensions:[1]}, System.Reflection.Binder binder = null, System.Reflection.BindingFlags invokeAttr = Default, System.Globalization.CultureInfo culture = null, System.Signature sig = {System.Signature}) + 0xc8 bytes 
  System.dll!System.ComponentModel.ReflectEventDescriptor.RemoveEventHandler(object component = {Plots=8}, System.Delegate value = {System.EventHandler}) + 0x155 bytes 
  System.dll!System.ComponentModel.ReflectPropertyDescriptor.RemoveValueChanged(object component, System.EventHandler handler) + 0xbc bytes 
  NationalInstruments.UI.dll!NationalInstruments.Restricted.PropertyChangePropertyDescriptor.RemoveValueChanged(object component = {Plots=8}, System.EventHandler handler = {System.EventHandler}) + 0x38 bytes 
  NationalInstruments.UI.dll!NationalInstruments.UI.PropertyEditorSource.Dispose(bool disposing = true) + 0x80 bytes 
  NationalInstruments.UI.dll!NationalInstruments.UI.PropertyEditorSource.Dispose() + 0x1d bytes 
  NationalInstruments.UI.WindowsForms.dll!NationalInstruments.UI.WindowsForms.PropertyEditor.Dispose(bool disposing = true) + 0x89 bytes 
  System.dll!System.ComponentModel.Component.Dispose() + 0xf bytes 
  System.Windows.Forms.dll!System.Windows.Forms.ToolStripControlHost.Dispose(bool disposing) + 0x39 bytes 
  NationalInstruments.UI.WindowsForms.dll!NationalInstruments.UI.WindowsForms.ToolStripPropertyEditor.Dispose(bool disposing = true) + 0xf7 bytes 
  System.dll!System.ComponentModel.Component.Dispose() + 0xf bytes 
  System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.Dispose(bool disposing = true) + 0x1a8 bytes 
  NationalInstruments.UI.WindowsForms.dll!NationalInstruments.UI.WindowsForms.InstrumentControlStrip.Dispose(bool disposing = true) + 0x85 bytes 
  System.dll!System.ComponentModel.Component.Dispose() + 0xf bytes 
  System.Windows.Forms.dll!System.Windows.Forms.Control.Dispose(bool disposing = true) + 0x170 bytes 
> GraphLibrary.dll!Opsens.Controls.LabViewChart.Dispose(bool disposing = true) Line 21 C#
I think the line is the root of all this:
 
NationalInstruments.UI.WindowsForms.dll!NationalInstruments.UI.WindowsForms.InstrumentControlStrip.Dispose(bool disposing = true) + 0x85 bytes 

 
The InstrumentControlStrip again, but this time at run time also.
 
Can you guys look into this?  I had done some basics checks on my own code to see if I was wrong using it at some point, but I found nothing apparently wrong. This was also in 8.2.1 and it is still in 8.5.
 
Thanks,
 
Jean Gauthier
Opsens
 
0 Kudos
Message 1 of 5
(5,473 Views)

After some investigation it turns out that this set of lines were producing the ArgumentException:

NationalInstruments

.UI.WindowsForms.ToolStripPropertyEditor toolStripCursors;

this.toolStripCursors.Source = new NationalInstruments.UI.PropertyEditorSource(this.ChartGraph, "Cursors");

NationalInstruments

.UI.WindowsForms.ToolStripPropertyEditor toolStripCursors;

this

.toolStripAnnotations.Source = new NationalInstruments.UI.PropertyEditorSource(this.ChartGraph, "Annotations");

ChartGraph is a WaveformGraph.

I discovered that when I had changed the InstrumentControlStrip for a simple System.Windows.Forms.ToolStrip and still noticing the exception. So I narrow down the suspect to the ToolStripPropertyEditor object.

Tks for your support,

Jean Gauthier

Opsens

0 Kudos
Message 2 of 5
(5,471 Views)
To show you that the InstrumentControlStrip is now out of the loop, here's the new error:
0 Kudos
Message 3 of 5
(5,470 Views)
Hi Jean,

I am a little confused as to the state you are in. Are you seeing this problem with or without Measurement Studio controls? If you are seeing this behavior with Measurement Studio controls, then we can look into the issue but we just need some small example that demonstrates the behavior.  If you are seeing buggy behavior with non-NI controls, then you should probably talk to Microsoft about that behavior.

Either way, just clarify where you are at now.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 4 of 5
(5,463 Views)

Jonathan,

Sorry about that. I'll try to be clearer.

The error come from NI component ToolStripPropertyEditor when inserted into either a ToolStrip or InstrumentControlStrip object. The confusion come from the fact that I first tought that the error was coming from the InstrumentControlStrip object.

a line like this DOESN'T produce errors:

this

.toolStripInteraction.Source = new NationalInstruments.UI.PropertyEditorSource(this.ChartGraph, "InteractionModeDefault");

but a line like this DOES:

this

.toolStripCursors.Source = new NationalInstruments.UI.PropertyEditorSource(this.ChartGraph, "Cursors");

The fact that a PropertyEditorSource is linked to a a collection of cursors (or annotations also) seems to produce the errors.

Thk,

Jean

0 Kudos
Message 5 of 5
(5,443 Views)