Serializing Derived Classes

Ok, I posted this in the wrong forum, so I'm trying again...

I'm trying to create a class that inherits from the System.Windows.Forms.TreeNode class.  I'm basically doing this to add a few properties to the class.  My question is how can I ensure that these properties are properly serialized.  If I was inheriting from one of my controls, I'd just do something like this:

public SCNNode(SerializationInfo si, StreamingContext context) : base (si, context)

and the function would search the serialization info object for a reference to my custom properties.

However, I can't do this since the TreeNode's serialization constructor is marked as internal.  Can anyone tell me how I can properly handle this

Thanks



Answer this question

Serializing Derived Classes

  • HP

    basically, you can't call the ctor because its internal. i guess this thread will help.

    WM_HOPETHISHELPS
    thomas woelfer

  • onskee

    A while back I saw a couple of examples of using reflection to call internal functions.  I don't think that this would work either, since I'd need to reference the constructor.

    Guess I'll be reinventing the wheel for one additional property.

  • mr_dipity

     rlbjr wrote:
    My question is how can I ensure that these properties are properly serialized.


    TreeNode is derived from MarshalByRefObject so you should consider perhaps not serializing it at all.  It depends on what you are serializing for.  If you are trying to persist your clas instance in (say) a disk file then you would want to serialize it, but if you are passing it between app domains  you'd want to actually serialize the objRef

  • Serializing Derived Classes