Bug 30667 - Binary serialized Dictionary<> not compatible with .Net
Summary: Binary serialized Dictionary<> not compatible with .Net
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-02 08:38 UTC by Vladimir
Modified: 2015-06-02 11:20 UTC (History)
2 users (show)

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


Attachments
Sample util for bug reproducing (1.71 KB, text/plain)
2015-06-02 08:39 UTC, Vladimir
Details


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:
Status:
RESOLVED FIXED

Description Vladimir 2015-06-02 08:38:23 UTC
Dictionary<> object serialized in mono sometimes can't be deserialized in .Net.

It is because of using custom IEqualityComparers (InternalStringComparer, IntEqualityComparer) for some basic types such as int, string and so on.

This comparers are also serialized during dictionary serialization. So .Net can't deserialize these comparers because there are no such types in .Net assemblies.

It's possible that other generic collections that used EqualityComparers are also can be bugged.

In attachment small sample.
Usage:
1) Serialize test dictionary:
SerializationBugSample.exe s path_to_output_file

2) Deserialize file as test dictionary:
SerializationBugSample.exe d path_to_input_file

So steps to reproduce:
1) On Linux: 
mono SerializationBugSample.exe s out.bin

2) Copy out.bin to Windows machine

3) On Windows: 
SerializationBugSample.exe d out.bin
Comment 1 Vladimir 2015-06-02 08:39:24 UTC
Created attachment 11424 [details]
Sample util for bug reproducing
Comment 2 Marek Safar 2015-06-02 10:55:17 UTC
Fixed in master and Mono 4.2
Comment 3 Vladimir 2015-06-02 11:00:34 UTC
If it's possible, can you tell in which commit this fix has been made?
Comment 5 Vladimir 2015-06-02 11:20:28 UTC
Thanks a lot! I just want to understand if it's possible to create patch for my version.