Copy Paste Issue


I want to copy/paste my objects inside a single GoView but no objects are pasted. Copyable objects in my app include GoNodes, Subgraphs, TextBoxes, and links. I have serialized all my classes and have used your serialization example to both store and retrieve my image. I’ve looked at the example (Demo1) code for copy/paste insights and used it as a starting point but I’m still missing a piece of the puzzle because nothing shows up when I do the paste. Here’s what I have so far:

  1. I have a context menu for each object class that has a copy menu item. When clicked, the associated method calls GoView.EditCopy (among other things). My copy command code was lifted directly from Demo1.
  2. Each object class overrides the CopyObject method, which returns the copied object.
  3. I have a context menu for my GoView which implements a paste menu item. When clicked, the associated method calls GoView.EditPaste (among other things). My paste command code was lifted directly from Demo1.

What else am I missing?

Thanks a lot.

R. Houston

sound like it may be a serialization problem. Try serializing to and from a file: See if you get any errors.

Also, you should have gotten some trace listener messages if there had been any caught exceptions. Look in Visual Studio's Output window, or implement your own trace listener.

Hi Jake,

Thanks for your reply.

Looks like my main form is flagged during the serialization process as being not serializable. My main form is based on, which I know from these forums is not serializable.

The problem is that I’m not trying to serialize my main form, just the goview.document that’s a part of the main form. Also, as far as I can tell none of my GoObjects’ member variables refer to the main form directly. One of my classes does hold on to a PingReply structure (.Net Framework structure) but I marked that as <nonSerialized()>.

Based on my findings do you believe that one of my GoObjects’ member variables, if not directly, is somehow indirectly referring back to the main form?

Thoughts, suggestions?


R. Houston

Hi Jake,

Well, it appears that Delegates are not serializable in my case. When I
apply the attribute to my two delegate member variables
the serialization is successful. Turns out that the delegates are pointing to methods in the main form, which is not serializable. I suppose that if my delegates had been pointing to methods in classes which were serializable then the delegates would have been serializable?

R. Houston

Doing a liitle Googling, serializing delegates seems to be a bad idea…

Hi Jake,

For what its worth I did a bit of experimenting and determined that yes, delegates will serialize if the invoked method is in a serializable class.
In fact, the method invoked in the serializable class utilizes its own delegate, which invokes a method in the main form, and the main form is not serializable. I’m not sure if what I’m doing is “approved” programming practice, but it works…so far.

For what its worth…

R. Houston