Deserialization is the process of using the serialized state
information to regain the object from the serialized shape to its original
shape.
So, it is basically the reverse process of the
Serialization. (The name also suggests De-Serialization)
The code below can be used for the De-serialization process.
Listing 3
Public Function DeSerializeData(ByVal oStream As System.IO.MemoryStream) _
As Object
Dim oFormatter As New _
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim oReturnObject As Object
oStream.Position = 0
oReturnObject = oFormatter.Deserialize(oStream)
Return oReturnObject
End Function
The function DeSerializeData De-serializes a MemoryStream
(which has been obtained by Serializing a Serializable object).
Here we need to add an extra line to seek the position of
the MemoryStream to ZERO (0).