binaryformatter

Serialiazing various types into one file

Hi. I'm using a BinaryFormatter to serialize my object. I have various object types in their relevant lists. Is there a 'best' way to serialize all the objects into one file, but be able to separate them on deserialization? At the moment, I'm deserializing the whole file and checking a specific field in each object to see what list I s...

BinaryFormatter alternative

I am shopping for a BinaryFormatter alternative/replacement. The current issues I have with BinaryFormatter (and the alternatives should address this) are 1) backwards compatibility (can deserialize Classes serialized using an earlier version) 2) size 3) speed I have checked out AltSerializer which looks ok, some conflicting re...

Performance: BinaryFormatter vs. XmlSerializer

I read very often that the BinaryFormatter has better performance then XmlSerializer. Out of curiosity, I wrote a test-app. a wtf moment... why is Xml so much faster than Bin (especially the deserialization)? using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Xml.Serialization; using Syste...

How to refactor a class that is serialized in .NET?

I have a C# class that is serialized to disk by the BinaryFormatter, such as this example: // Version 3.0 [Serializable] public class Person { public string FullName; [OptionalField(VersionAdded=2)] public string NickName; [OptionalField(VersionAdded=2)] public DateTime BirthDate; [OptionalField(VersionAdded=3)...

Backwards compatibility in .NET with BinaryFormatter

We use BinaryFormatter in a C# game, to save user game progress, game levels, etc. We are running into the problem of backwards compatibility. The aims: Level designer creates campaign (levels&rules), we change the code, the campaign should still work fine. This can happen everyday during development before release. User saves game, w...