P
PCH
I have 2 functions, one to serialize an object, and one to deserialize it.
I can serialize just fine, the problem is when I try to deserialize it
later...
I get an error:
{"Invalid BinaryFormatter stream. " }
I looked at the serialized string vs whats passed into the deserialize
method and they are exactly the same!
Heres the serialize code:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms=new MemoryStream();
bf.Serialize(ms,p_Object);
string sResult = System.Text.Encoding.ASCII.GetString(ms.ToArray());
ms.Close();
ms = null;
bf = null;
Heres the deserialize code:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms=new
MemoryStream(System.Text.Encoding.ASCII.GetBytes(p_SerialString));
object oObject = new object();
try
{
oObject = bf.Deserialize(ms);
}
catch (Exception ex)
{
string s = ex.Message;
}
ms.Close();
ms = null;
bf = null;
I can serialize just fine, the problem is when I try to deserialize it
later...
I get an error:
{"Invalid BinaryFormatter stream. " }
I looked at the serialized string vs whats passed into the deserialize
method and they are exactly the same!
Heres the serialize code:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms=new MemoryStream();
bf.Serialize(ms,p_Object);
string sResult = System.Text.Encoding.ASCII.GetString(ms.ToArray());
ms.Close();
ms = null;
bf = null;
Heres the deserialize code:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms=new
MemoryStream(System.Text.Encoding.ASCII.GetBytes(p_SerialString));
object oObject = new object();
try
{
oObject = bf.Deserialize(ms);
}
catch (Exception ex)
{
string s = ex.Message;
}
ms.Close();
ms = null;
bf = null;