Binary serialization - How to handle renamed types?

DanielM

Newcomer
Joined
Jul 20, 2004
Messages
7
We use binary serialization for persisting some of the data of our application. Now, after some refactoring (assembly names and namespaces changed) has been done, we ran into problems with deserialization of previously (before refactoring) persisted data.

Has someone found a working solution how to migrate the binary data without manipulating it at file level?

As far as I have seen, assembly name and the full qualified type names are stored in the serialized files.

I have some ideas, e.g. building a small app that binds both versions of the assembly where the serialized types are stored in. On one side I would deserialize the persisted data using the old version, then transform the objects to the new definition (via reflection) and serialize them again.

Probably someone has a solution that is more simple to implement... :D

Thanks,
Daniel
 
You might be able to throw together a q&d fix, but I think your proposed solution might be along the right lines. Out of curiosity, is the issue that the type names are different or is the actual binary structure of the data changed?
 
The inner structure of the classes are exactly the same. Just the assembly names and some of the namespaces have changed.
 
Then perhaps it would be best to reference the old version of the assembly and use that to load the data. If it would cause name conflicts and what not, reflection would probably be a viable solution.
 
Back
Top