问题
I have a binary file that was serialized from a class. That class has been updated.
Now I need to deserialize the old file to the new class.
I don't have access to the old code, but i have access to the old class.
The Class was serialized using BinaryFormatter.
Is there a way to do that?
If not, maybe there a way to deserialize and save only the data that appears in both of the versions?
回答1:
If you have the old assembly you can upgrade quite easily by:
- deserialize to objects with old class type
- write a mapper mapping old data fields to the fields in the new class
- serialize the objects of the new class
In the mapper you can convert the old data, add new data etc.
来源:https://stackoverflow.com/questions/15954054/deserialize-to-newer-version