M
Mark Olbert
I need some help dealing with deserializing objects using BinaryFormatter when the assembly version changes. Nothing about the
structure of the class being deserialized has changed; just the version of the assembly that defines it.
My understanding is that, by default, BinaryFormatter.Deserialize() blows up with an assembly not found exception if you try to
deserialize an object created with an earlier version of the same, unchanged assembly. Personally, I think that's a weird default.
Or maybe the folks who wrote that code always get their programs right the first time, so they never deal with assembly version
changes .
In any event, it looks like the SerializationBinder class exists to resolve this problem, by "mapping" one type to another.
In my app I've derived a class from SerializationBinder which handles the version changes. It returns the correct new Type for each
old Type it's given.
However, Deserialize() is still blowing up with a FileNotFound exception, claiming that one of the required assemblies, or a
dependency of same, cannot be found.
1) How can I verify precisely which version of the "missing" assembly is being sought? I've run fuslogvw.exe, but it's not
displaying anything.
2) How can I determine if it's a dependent assembly that's missing? And, if that's the problem, how do I inform the deserialization
engine where to find the new assembly?
3) Am I on the right track using SerializationBinder to solve this problem? If not, what should I do?
- Mark
structure of the class being deserialized has changed; just the version of the assembly that defines it.
My understanding is that, by default, BinaryFormatter.Deserialize() blows up with an assembly not found exception if you try to
deserialize an object created with an earlier version of the same, unchanged assembly. Personally, I think that's a weird default.
Or maybe the folks who wrote that code always get their programs right the first time, so they never deal with assembly version
changes .
In any event, it looks like the SerializationBinder class exists to resolve this problem, by "mapping" one type to another.
In my app I've derived a class from SerializationBinder which handles the version changes. It returns the correct new Type for each
old Type it's given.
However, Deserialize() is still blowing up with a FileNotFound exception, claiming that one of the required assemblies, or a
dependency of same, cannot be found.
1) How can I verify precisely which version of the "missing" assembly is being sought? I've run fuslogvw.exe, but it's not
displaying anything.
2) How can I determine if it's a dependent assembly that's missing? And, if that's the problem, how do I inform the deserialization
engine where to find the new assembly?
3) Am I on the right track using SerializationBinder to solve this problem? If not, what should I do?
- Mark