asanford
2006-07-06 21:45:01 UTC
The MSDN documentation, along with various articles online, such as this one
http://msdn.microsoft.com/msdnmag/issues/04/10/AdvancedSerialization/
claim that the BinaryFormatter will throw an exception if you try to
deserialize a stream that has missing members in it, and that the new
OptionalFieldAttribute allows you to avoid this problem, by marking the new
members as optional. Well, it seems that even if you don't specify this
attribute, no exceptions are thrown, no matter if you add members, remove
members, or change the assembly version. I also did tests with both signed
and unsigned assemblies, and it made no difference. Is there some other
global setting that could affect the behavior? I thought maybe the
BinaryFormatter.AssemblyFormat might be set to simple, but the doc says the
default is for Full, not Simple (I'm doing all my tests with the caching
application block's isolated storage backing, which I don't think changes the
AssemblyFormat from the default.) I also looked into the files containing
the serialized data, and I can see the assembly name, version number, public
key, etc., so I'm fairly sure AssemblyFormat is set to Full.
Any help?
BTW, I also found the following post indicating someone else already found
this problem:
http://groups.google.com/group/microsoft.public.dotnet.framework/browse_thread/thread/465a8713be2f153/173410a79ee7de1a?lnk=st&q=OptionalFieldAttribute+BinaryFormatter&rnum=1&hl=en#173410a79ee7de1a
Thanks!
http://msdn.microsoft.com/msdnmag/issues/04/10/AdvancedSerialization/
claim that the BinaryFormatter will throw an exception if you try to
deserialize a stream that has missing members in it, and that the new
OptionalFieldAttribute allows you to avoid this problem, by marking the new
members as optional. Well, it seems that even if you don't specify this
attribute, no exceptions are thrown, no matter if you add members, remove
members, or change the assembly version. I also did tests with both signed
and unsigned assemblies, and it made no difference. Is there some other
global setting that could affect the behavior? I thought maybe the
BinaryFormatter.AssemblyFormat might be set to simple, but the doc says the
default is for Full, not Simple (I'm doing all my tests with the caching
application block's isolated storage backing, which I don't think changes the
AssemblyFormat from the default.) I also looked into the files containing
the serialized data, and I can see the assembly name, version number, public
key, etc., so I'm fairly sure AssemblyFormat is set to Full.
Any help?
BTW, I also found the following post indicating someone else already found
this problem:
http://groups.google.com/group/microsoft.public.dotnet.framework/browse_thread/thread/465a8713be2f153/173410a79ee7de1a?lnk=st&q=OptionalFieldAttribute+BinaryFormatter&rnum=1&hl=en#173410a79ee7de1a
Thanks!