Losing my UserObject

I am using 2.6.2
I am losing my UserObject assignment. I am using a GoToolCreatings assigned as the GoToolRubberbanding with a prototype, in the Stop() method, I assign it.
When debugging I see it in the Stop method, but if I break later and look, it is null (using watch to drill down to the document layer objects).
I set up a small test and it works fine, so I am sure it is my bug, but I was wondering if you had seen this before?
The class is derived from GoTextNode, but so was my test and that worked.
Thanks for any help.
I am able to recreate it, so I will send in the code

Here is the code:

public partial class Form1 : Form { private MyToolCreating _tool; public Form1() { InitializeComponent(); _tool = new MyToolCreating(this.goView1); this.goView1.ReplaceMouseTool(typeof(GoToolRubberBanding), _tool); } private void button2_Click(object sender, EventArgs e) { foreach (GoObject obj in this.goView1.Document) { if (obj is MyNode) { MyNode node = (MyNode)obj; if (node.UserObject == null) MessageBox.Show("Node UserObject is Null"); } } } } public class MyNode : GoTextNode {

private GoDocument _doc;
public MyNode(GoDocument doc) {
_doc = doc;
_doc.Changed += new GoChangedEventHandler(_doc_Changed); // Not shown
this.AutoResizes = false;
this.AutoResizes = false;
this.Brush = Brushes.LightBlue;
this.Editable = true;
this.DragsNode = true;
this.Reshapable = true;

class MyToolCreating : GoToolCreating { private MyNode _node; public MyToolCreating(GoView view) : base(view) { } public override void Start() { base.Start(); _node = new MyNode(this.View.Document); this.Prototype = _node; } public override void Stop() { _node.UserObject = new Class1(); System.Windows.Forms.MessageBox.Show("This is the stop method of the tool and the UserObject is " + _node.UserObject.ToString()); base.Stop(); } }
public class Class1 { // Just a dummy class private int _1; public int id1 { get { return _1; } set { _1 = value; } } private int _id2; public int ID2 { get { return _id2; } set { _id2 = value; } } private int _id3; public int id3 { get { return _id3; } set { _id3 = value; } } }
Undo will reset UserObject for Nodes, Links and Ports.
Samples Classier, DataSetDemo, FamilyTree, Flowgrammer, Orgcharter, ProtoApp all use UserObject.
but no other code we ship sets UserObject.

I am not calling Undo and I am not using the UndoManager, I will check out those samples. I looked in demo1, but not the others…


OK, it seems that I need to create the UserObject in the Start Method, I was storing a reference to the prototype object in the tool, _MyNode.

Then in the Stop I updated that member variable, if I assign it in start things seem better in my test, so I'll try it in the big program.

Just an update for anyone else who might have this problem. Don’t store your prototype as a member var in the tool, use the Prototype member.

I said I had to create it in Start, which is not true. I accessed it in Stop with this code:
public override void Stop() { MyNode node = this.Prototype as MyNode;
... }
It had my userObject, but it seemed that I could not then set a UserFlags value, so I am doing all assignment in the start() proc.