G
Guest
Does anyone know why this code gives an error:
<serializeable> public structure TestSerialize
anumber as integer
astring as string
end strucuture
Dim t As TestSerialize
Dim formatter As New BinaryFormatter
Dim s As New MemoryStream
t.anumber = 125
t.astring = "This is a test of Serialilzing a structure"
formatter.Serialize(s, t)
t = DirectCast(formatter.Deserialize(s), TestSerialize) ' This lines give
an error
saying that end of memory stream found before parsing was completed.
<serializeable> public structure TestSerialize
anumber as integer
astring as string
end strucuture
Dim t As TestSerialize
Dim formatter As New BinaryFormatter
Dim s As New MemoryStream
t.anumber = 125
t.astring = "This is a test of Serialilzing a structure"
formatter.Serialize(s, t)
t = DirectCast(formatter.Deserialize(s), TestSerialize) ' This lines give
an error
saying that end of memory stream found before parsing was completed.