A
alexandre martins
Every time i try to make Deserialize the computer gives me
the folowing error:
"End of Stream encountered before parsing was complete"
the code that i'm running is simple and is based on an
MSDN example. The CODE is BELOW this lines. If you see
something wrong or missing please answer.
Class declaration:
<Serializable()> Public Class MyO
Public n1 As Integer = 0
Public n2 As Integer = 0
Public str As String = String.Empty
End Class 'MyO
Code:
Dim objecto As New MyO()
Dim exp As New MyO()
Dim s As New System.IO.MemoryStream()
Dim formatter As New _
System.Runtime.Serialization. _
Formatters.Binary.BinaryFormatter()
objecto.n1 = 1
objecto.n2 = 2
objecto.str = "ola"
s.Capacity() = 256000
formatter.Serialize(s, objecto)
Try
exp = CType(formatter.Deserialize(s), MyO)
Catch erro As Exception
MessageBox.Show(erro.Message.ToString())
End Try
the folowing error:
"End of Stream encountered before parsing was complete"
the code that i'm running is simple and is based on an
MSDN example. The CODE is BELOW this lines. If you see
something wrong or missing please answer.
Class declaration:
<Serializable()> Public Class MyO
Public n1 As Integer = 0
Public n2 As Integer = 0
Public str As String = String.Empty
End Class 'MyO
Code:
Dim objecto As New MyO()
Dim exp As New MyO()
Dim s As New System.IO.MemoryStream()
Dim formatter As New _
System.Runtime.Serialization. _
Formatters.Binary.BinaryFormatter()
objecto.n1 = 1
objecto.n2 = 2
objecto.str = "ola"
s.Capacity() = 256000
formatter.Serialize(s, objecto)
Try
exp = CType(formatter.Deserialize(s), MyO)
Catch erro As Exception
MessageBox.Show(erro.Message.ToString())
End Try