EditCopy() Got Exception Error


#1
I'm got error while trying to copy GoGroup ( GoBox , GoImage) to new node the exception message here -> Why error ? , this node can delete, can move but can't copy! or error came from GoDiagram BUG ???

EditCopy: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.ArrayListEnumeratorSimple.MoveNext()
at NodeEditor.GetDigitsNode.CopyObject(GoCopyDictionary env) in d:\users\suwit\sunproduct\nodeeditor2003\nodeinfo\getdigitsn ode.cs:line 521
at Northwoods.Go.GoCopyDictionary.Copy(GoObject obj)
at Northwoods.Go.GoDocument.CopyFromCollection(IGoCollection coll, Boolean copyableOnly, Boolean dragging, SizeF offset, GoCopyDictionary env)
at Northwoods.Go.GoView.CopyToClipboard(IGoCollection coll)
at Northwoods.Go.GoView.EditCopy()


#2

I don’t know–clearly the error is saying that you are trying to modify a collection while you are iterating over it, in GetDigitsNode.CopyObject. You’ll need to examine your code carefully and debug it. Perhaps you are adding things to the original collection that you are copying, instead of to the new collection.


#3

Walter,
Here’s my snippet code that cause of exception, please advise.
public override GoObject CopyObject(GoCopyDictionary env)
{
// GetDigitsNode newobj = (GetDigitsNode) base.CopyObject(env); GetDigitsNode newobj = base.CopyObject(env) as GetDigitsNode;

if (newobj != null)
{
try
{
if (newobj.Cases.Count<=0)
{
newobj.Cases = new CaseEventCollection(); //(CaseEventCollection)env[m_CaseEventCollection];
foreach(CaseEvent ca in this.Cases)
{
newobj.Cases.Add(ca);
}
}
if (newobj.VariableToReceiveResult.Count<=0)
{
newobj.VariableToReceiveResult = new MyVariableCollection();
foreach(VariableList v in this.VariableToReceiveResult)
{
newobj.VariableToReceiveResult.Add(v);
}
}
}
catch{ }
newobj.UserObject = new GetDigitsNodeInfo(newobj);
}
return newobj;
}


#4

You’re not sharing the collection of cases, but did you want to share each CaseEvent? And the same question for VariableLists.
I’m sorry, but I can’t really understand your code.


#5

the purpose is i want to copy my owner infomation in field “.UserObject” (which contained 2 collections object “Cases” and VariableList) ,
Because when i copy myGoObject to new location the information in node( userobject ) not copied. only main node copied to new location that why i need to manually add with :
newobj.UserObject = new GetDigitsNodeInfo(newobj);

Any idea, please help
Regards,
Suwit.