Yes, you need to implement a Serialization constructor for types implementing ISerializable; that serialization constructor is responsible for deserializing the object as it did for serialization using GetObjectData
method.
Serialization constructor will look something like this, with first parameter SerializationInfo
and second StreamingContext
.
protected ClassName(SerializationInfo info, StreamingContext context)
{
}
Remarks section in the provided link talks about this topic.
The ISerializable interface implies a constructor with the signature constructor (SerializationInfo information, StreamingContext context). At deserialization time, the current constructor is called only after the data in the SerializationInfo has been deserialized by the formatter. In general, this constructor should be protected if the class is not sealed.