Deserialize object into assembly that is now signed and versioned

后端 未结 3 667
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 22:23

I used to serialize a treeview with the BinaryFormatter (c#). The Assembly that did just that and which contains the all the serializable classes has now a strong name and i

3条回答
  •  迷失自我
    2021-01-04 23:00

    You could try using a serialization surrogate, but without something we can reproduce it will be hard to give a decent answer.

    The fundamental problem, however, is that BinaryFormatter is simply very, very brittle when it comes to things like assemblies. Heck, it is brittle enough even within an assembly.

    It sounds like TreeViewData is tree based, so I wonder whether xml would have been a better (i.e. more version tolerant) option. If efficiency is a concern, there are custom binary formats (like protobuf-net) that offer high performance, version tolerant, portable binary serialization. If your data is already serialized... I wonder if it might be time to change track? Try using the old assembly to deserialize the data, and switch to a more robust serialization strategy.

提交回复
热议问题