Undo operation causing ArgumentOutOfRang


#1
Walter,
I'm receiving the following error periodically when I call Undo. Any idea why this is happening?
System.ArgumentOutOfRangeException' in northwoods.go.dll
Additional information: Specified argument was out of the range of valid values.
Thanks,
Erik

#2

I haven’t seen that error in years, since when we were implementing undo/redo support long before we first released any version of GoDiagram.
It’s likely the error is occuring in some implementation of GoObject.ChangeValue, as an undo is being performed on a GoChangedEventArgs. Can you narrow down the kind of operation that you are undoing?


#3
This is want I've narrowed it down to so far.
When this transaction is complete and I try to do an UNDO the exception is thrown.
this.Document.StartTransaction();
this.Changed(0, 0, 0, this.Bounds, 0, 0, this.Bounds);
this.Text = dlg.NodeName;
this.Label.TextColor = dlg.NodeColor;
this.Label.Font = dlg.NodeFont;
this.Description = dlg.NodeDescription;
this.Document.FinishTransaction("Node properties changed");

#4
I forgot to mention...
dlg.NodeFont is returning type System.Drawing.Font
dlg.NodeColor is returning type System.Drawing.Color

#5

I haven’t tried that code, but that call to Changed(0, …) looks suspicious. Try removing that line.
What class is this code defined in? What version of GoDiagram Win(?) are you using?


#6
I'm using Win 2.1.2 and I have several classes. The base class for the above example is GoIconicNode. I have several custom properties that I have added to the class and their values are being changed in between the StartTransaction() - FinishTransaction() calls. Could this be causing a problem? I've tried adding a Changed(...) call with values of the changed custom properties but the same exception is being thrown.
If I remove calls to Changed(...) the exception is still thrown. The only time it is not thrown is if I only modify a property that is in GoIconicNode, not in my derived class.
Hope that helps!
Thanks,
Erik

#7

Well, you must be referring to the Description property, which I assume is something you defined. Then the error is raised by GoObject.ChangeValue, when it sees a hint value that it doesn’t recognize.
You just need to override ChangeValue to handle your particular “ChangedDescription” hint case. There are lots of examples of this in the sample applications.