D
Derek Martin
Hey list, I have an arraylist containing some objects that I want to
serialize and send over the internet and then deserialize back into the
arraylist of objects.
What I have so far:
Dim myfeeds As New ArrayList
myfeeds = <<method that populates arraylist with objects>>
Dim BinFormatter As New
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim memStream As New System.IO.MemoryStream
BinFormatter.Serialize(memStream, myfeeds)
memStream.Position = 0
Dim stremRead As New System.IO.StreamReader(memStream)
Dim oEncoder As New System.Text.ASCIIEncoding
Dim thisbyte As Byte() = oEncoder.GetBytes(stremRead.ReadToEnd)
Dim thisbase64 As String = Convert.ToBase64String(thisbyte)
then, send thisbase64 string across the net...so far so good?
Now, I need to take this back into arraylist, and am probably just having a
brain fart but am unable to get this order properly reversed:
Dim bytes2 As Byte() = Convert.FromBase64String(thisbase64)
Dim memstream2 As New System.IO.MemoryStream(bytes2)
Dim stremread2 As New System.IO.StreamWriter(memstream2)
Dim mysecondfeeds As ArrayList =
CType(BinFormatter.Deserialize(memstream2), ArrayList)....causes format
change exception
annnnnd.....brain fart
Anyone can help???
Thanks,
Derek
serialize and send over the internet and then deserialize back into the
arraylist of objects.
What I have so far:
Dim myfeeds As New ArrayList
myfeeds = <<method that populates arraylist with objects>>
Dim BinFormatter As New
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim memStream As New System.IO.MemoryStream
BinFormatter.Serialize(memStream, myfeeds)
memStream.Position = 0
Dim stremRead As New System.IO.StreamReader(memStream)
Dim oEncoder As New System.Text.ASCIIEncoding
Dim thisbyte As Byte() = oEncoder.GetBytes(stremRead.ReadToEnd)
Dim thisbase64 As String = Convert.ToBase64String(thisbyte)
then, send thisbase64 string across the net...so far so good?
Now, I need to take this back into arraylist, and am probably just having a
brain fart but am unable to get this order properly reversed:
Dim bytes2 As Byte() = Convert.FromBase64String(thisbase64)
Dim memstream2 As New System.IO.MemoryStream(bytes2)
Dim stremread2 As New System.IO.StreamWriter(memstream2)
Dim mysecondfeeds As ArrayList =
CType(BinFormatter.Deserialize(memstream2), ArrayList)....causes format
change exception
annnnnd.....brain fart
Anyone can help???
Thanks,
Derek