Backwards compatibility in .NET with BinaryFormatter

后端 未结 3 1260
广开言路
广开言路 2020-12-31 12:43

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:

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 13:26

    Tough one. I would dump binary and use XML serialization (easier to manage, tolerant to changes that are not too extreme - like adding / removing fields). In more extreme cases it is easier to write a transform (xslt perhaps) from one version to another and keep the classes clean. If opacity and small disk footprint are a requirement you can try to compress the data before writing to disk.

提交回复
热议问题