I recently implemented a Copy&Paste feature into an application I am working on. This works pretty much as intended.
I create a new item in my user interface and can copy and paste it as often as I want without any issues.
But when I copy&paste an item that was produced by a previous copy&paste action, I get a SerializationException
. It complains about a certain type not being marked as serializable.
This is where the confusion starts. The first copy&paste action interacts with the same kind of objects as the second. But the second results in the exception.
To be a little more detailed, I have a class Slide
, this is the class that is the target of the copy&paste operation. So, I place an instance of that object in the clipboard and paste it again into the same container. This works out as intended. Now I copy that inserted object and it try to paste it. This is when the exception is thrown. The exception complains about a class SlideEditorUi
. SlideEditorUi
is a UserControl
that interacts with a class called SlideEditor
. Which in turn interacts with a Slide
instance. But no Slide
instance has a reference back to any of the for-mentioned classes.
So I am really wondering why the serialization procedure takes this class into account. And why does it only do that when I copy a copy?