Home All Groups Group Topic Archive Search About

Deserialzing delegates using a customer formatter

Author
11 Jan 2005 8:00 PM
Jerry Rig
I'm writing my own custom serialization formatter (i.e. implementing
the System.Runtime.Serialization.IFormatter interface).  I've managed
to get it to serialize and deserialize all serializable types except
delegates.

The System.Delegate class implements the
System.Runtime.Serialization.ISerializable interface, so I can
serialize it pretty easily as it's GetObjectData method returns a
popualted System.Runtime.Serialization.SerializationInfo object.  The
problem is with deserialization.  System.Delegate does not declare a
deserialization constructor (and neither do any Delegate subclasses),
so I can't construct it as I would any other type that implements
ISerializable.

Does anyone know the trick to deserializing delegates?  The closest
thing I can figure is making use of one of the static
System.Delegate.CreateDelegate methods.  However, that would require
that I parse the SerializationInfo object itself to create the
parameters necessary for those methods.  I have to believe logic
already exists in the framework to do this.

Thanks!
~pete

AddThis Social Bookmark Button