Bug 8520 - [patch] BinaryFormatter cannot deserialize data from other implementations when base types are encoded with full names
Summary: [patch] BinaryFormatter cannot deserialize data from other implementations wh...
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2012-11-19 21:27 UTC by David McFarland
Modified: 2015-03-17 03:04 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

patch (2.91 KB, patch)
2012-11-19 21:27 UTC, David McFarland
testcase (2.24 KB, patch)
2012-11-21 19:27 UTC, David McFarland

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description David McFarland 2012-11-19 21:27:30 UTC
Created attachment 2973 [details]

BinaryFormatter encodes serializable, non-public fields in base types of an object as:


Mono looks up the chain of base types and finds the first one whose 'Name' matches the left of the +.  In cases where the actual type is not the first in the inheritance chain with the same 'Name', other implementations may write out the 'FullName' of the type on the left of the +.  When reading one of these objects, mono will fail to load the type information for the field, skip de-serialization, and end up with a corrupt stream (various SerializationExceptions).

I've attached a patch that will allow 'FullName'+fieldName to be resolved in de-serialization, and the 'FullName'+fieldName to be written in serialization when the base type is not the first one in the chain with the same 'Name'.

I'll write a test for this problem as soon as I get a chance.
Comment 1 David McFarland 2012-11-21 19:27:44 UTC
Created attachment 2994 [details]

Here's a test that fails on both net_2_0 and default profile without the above patch.
Comment 2 Marek Safar 2015-03-17 03:04:44 UTC
Fixed in master