Error trying to drag and drop between app instances (of same app)

D

Derrick

I have a basic C# windows forms app where drag and drop of a simple class, no gui, from one tree to another (I store the class instance in the "tag" field of the tree nodes, and drag that) That is working fine within the same app instance. If I start two instances of the same app and try to drag from one app instance to the other, I get the below exception:

A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in system.windows.forms.dll

Additional information: The type System.Windows.Forms.DataObject in Assembly System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable.

What I don't understand is that I am calling DoDragDrop on the tree view, but the object I am telling it to dnd is not windows forms derived, and it contains no windows forms reference.

treeView1.SelectedNode = (TreeNode)e.Item;
MyObject objToDrag = (MyObject)((TreeNode)e.Item).Tag;
treeView1.DoDragDrop(objToDrag,DragDropEffects.Copy|DragDropEffects.Move);

In the above example, MyObject is marked as Serializable, and I can successfully pass instances of it across a Web Service boundry.

Guessing this has something to do with the TreeView itself?

Thanks in advance!

Derrick
 
D

Derrick

think this was simply due to the fact that I was debugging one app instance, run both instances outside the IDE and works as expected!

I have a basic C# windows forms app where drag and drop of a simple class, no gui, from one tree to another (I store the class instance in the "tag" field of the tree nodes, and drag that) That is working fine within the same app instance. If I start two instances of the same app and try to drag from one app instance to the other, I get the below exception:

A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in system.windows.forms.dll

Additional information: The type System.Windows.Forms.DataObject in Assembly System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable.

What I don't understand is that I am calling DoDragDrop on the tree view, but the object I am telling it to dnd is not windows forms derived, and it contains no windows forms reference.

treeView1.SelectedNode = (TreeNode)e.Item;
MyObject objToDrag = (MyObject)((TreeNode)e.Item).Tag;
treeView1.DoDragDrop(objToDrag,DragDropEffects.Copy|DragDropEffects.Move);

In the above example, MyObject is marked as Serializable, and I can successfully pass instances of it across a Web Service boundry.

Guessing this has something to do with the TreeView itself?

Thanks in advance!

Derrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top