BinaryFormatter behaving in weird way in my code. I have code like following
[Serializable]
public class LogEntry
{
private int id;
private List<object> data = new List<object>();
public int Id
{
get { return id; }
}
public IList<object> Data
{
get { return data.AsReadOnly(); }
}
...
}
....
....
private static readonly BinaryFormatter logSerializer = new BinaryFormatter();
....
....
public void SerializeLog(IList<LogEntry> logEntries)
{
using (MemoryStream serializationStream = new MemoryStream())
{
logSerializer.Serialize(serializationStream, logEntries);
this.binarySerializedLog = serializationStream.GetBuffer();
}
}
In some machine (32 or 64 bit machine), it is serializing in binary format - which is expected. But in some machine ( all of them are 64 bit machine and not for debug builds) it is not serializing, binarySerializedLog is showing ToString() value of all individual Data, class name (...LogEntry) and id value. My question is - are there specific reason for this type of behavior or am I doing some mistake? Thanks in advance.