Hi!
I am trying to find out how big is one of my entity object with it's subordinate objects when serialized with binary formatter. I saved serialized object to file, but when I tried to deserialize it, I got the Exception with message "End of Stream encountered before parsing was completed". By getting that message, I am not sure anymore that I even performed serialization in proper way.
DataEntity data = DataManager.GetData(100);
FileStream writeStream = new FileStream("MyData.bin", FileMode.Create, FileAccess.Write);
IFormatter formatter = new BinaryFormatter();
try
{
formatter.Serialize(writeStream, data);
}
catch (SerializationException ex)
{
Debug.WriteLine(ex.Message);
}
finally
{
writeStream.Close();
}
Stream readStream = new FileStream("MyData.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
DataEntity readData = null;
try
{
readData = (DataEntity)formatter.Deserialize(readStream);
}
catch (SerializationException ex)
{
Debug.WriteLine(ex.Message);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
finally
{
readStream.Close();
}
DataEntity is entity object generated from template provided with LLBLGen Pro 1.2004.1.
Can anyone tell me where the problem is?
Thanks.