问题描述
我正在实施一个项目,我有一个复杂的状态对象,需要存储起来并在以后由数字消耗不同的服务。
这个状态对象的本质是它会在向对象添加附加属性的地方进化。
我担心的是,对象的旧版本随着对象的每次演变都会在反序列化过程中失败。
我''我们使用 ISerializable
查看了自定义序列化的使用,并通过将 NonSerialized
属性应用于任何来帮助默认序列化过程新物业。
我希望得到的一些反馈来自以前遇到过此类问题的开发商,如果他们指出一些坑跌落或使用 ISerializable
或 NonSerialized
方法出现问题,或者推荐一个第三种方法我还没考虑过?
Hi,
I''m implementing a project where I have a complex state object which needs to be stored away and at a later date consumed by a number of different services.
The nature of this state object is that it is going to evolve where additional properties are added to the object.
My concern is that older versions of the object are going to fail the deserialization process with each evolution of the object.
I''ve looked into the use of custom serialization using ISerializable
and also aiding the default serialization process by applying the NonSerialized
attribute to any new properties.
What I''m hope for is some feedback from developers who''ve previously faced this type of issue and if they point out some pit falls or problems with either the ISerializable
or NonSerialized
approach, or perhaps recommend a third approach I haven''t yet contemplated?
推荐答案
这篇关于序列化版本管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!