DoExternalDrop w/ different GoViews/Docs

In the application I’m working on, the GoView method DoExternalDrop(DragEventArgs) is overwritten in a similar fashion as in the Demo1 sample app. While this works fine when dropping nodes from the treeview, when a selection is dragged into a view from a different window, problems are occuring. In that case, base.DoExternalDrop(DragEventArgs) is called. The objects copied into the new Document have references back to the original Document. Therefore when a user right clicks on the object, the menu appears in the other window. Even worse, if the origination window is closed, a fatal error occurs when the user right clicks.
System.ArgumentException: ContextMenu cannot be shown on an invisible control.
Parameter name: control
at System.Windows.Forms.ContextMenu.Show(Control control, Point pos)
at {myclass}.ShowMenu(GraphView view, Point pos) in {myclass}.cs:line ###
at {myapp}.GraphView.node_ContextClick(Object sender, GoInputEventArgs e) in {MyApp}\GraphView.cs:line ###
at {myapp}.ContextClickEventHandler.Invoke(Object sender, GoInputEventArgs e)
at {myapp}.GraphNode.OnContextClick(GoInputEventArgs e) in {myapp}\GraphNode.cs:line ###
at {myapp}.GraphNode.OnContextClick(GoInputEventArgs evt, GoView view) in {myapp}\GraphNode.cs:line ###
at Northwoods.Go.GoView.DoContextClick(GoInputEventArgs evt)
at Northwoods.Go.GoToolContext.DoMouseUp()
at Northwoods.Go.GoView.DoMouseUp()
at Northwoods.Go.GoView.OnMouseUp(MouseEventArgs evt)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&a mp; m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&amp ; m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
ContextMenu cannot be shown on an invisible control.
Parameter name: control
at System.Windows.Forms.ContextMenu.Show(Control control, Point pos)
at {some-class}.ShowMenu(GraphView view, Point pos) in {class1}.cs:line ###
at {some-class}.node_ContextClick(Object sender, GoInputEventArgs e) in {some-class}.cs:line ###
at {some-class}.ContextClickEventHandler.Invoke(Object sender, GoInputEventArgs e)
at {some-class}.OnContextClick(GoInputEventArgs e) in {class4}.cs:line ###
at {some-class}.OnContextClick(GoInputEventArgs evt, GoView view) in {some-class}.cs:line ###
at Northwoods.Go.GoView.DoContextClick(GoInputEventArgs evt)
at Northwoods.Go.GoToolContext.DoMouseUp()
at Northwoods.Go.GoView.DoMouseUp()
at Northwoods.Go.GoView.OnMouseUp(MouseEventArgs evt)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&a mp; m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&amp ; m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I tried explicitly calling GoDocument.CopyFromCollection and encountered the same problem. However, copying from the one document into the clipboard and pasting the selection into the second document does not have this same problem. What should I be doing to strip out the references to the other document that is done when moving through the clipboard but not through the default drag and drop behavior?

Is that you Jason?
You probably need to override GoObject.CopyObject to fix up those references to the old GoDocument or GoView. (Examples are in the samples directory.)
When copied into and pasted from the clipboard, the copied GoDocument is serialized and deserialized. I am guessing that those bad references aren’t being copied, perhaps because you marked those fields as [NonSerialized].
As a general principal, it’s important not to have any GoView or view-related references, or references to any other Controls, in any GoObjects may be part of a GoDocument.

Walter, yup, it’s me. Thanks for the tip. My company just took over from another firm on the project I’m working on, and we’re in the process of sorting through all the inherrited code from the previous developers… You may see me posting on the forum on occasion when I’m unsure of exactly how they were using GoDiagram. Thanks in advance for the help!
~Jason