[Mono-bugs] [Bug 474009] New: Serialize and Deserialize using BinaryFormatter on an empty Dictionary<K, V> incompatible with MS.NET

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Feb 9 13:01:35 EST 2009


           Summary: Serialize and Deserialize using BinaryFormatter on an
                    empty Dictionary<K,V> incompatible with MS.NET
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jaebird at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=271318)
 --> (https://bugzilla.novell.com/attachment.cgi?id=271318)
Test app showing the problem

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
Gecko/2008070208 Firefox/3.0.1

It may seem silly, but the serialization/deserialization between Mono 2.2 and
NET 2.0 of an empty Dictionary is incompatible. The binary data created by
Mono includes "KeyValuePairs" so .NET throws an exception that it cannot find
"keys". If you take a .NET serialized object to mono, the exception is that "No
element named KeyValuePairs" could be found.

If you add at least one element to the dictionary, there error goes away. This
was found because a data class includes a dictionary that just happened to be
empty. The workaround for this issue is to set the dictionary as
NonSerializable and then manually serialize the data as a pair of arrays.

Reproducible: Always

Steps to Reproduce:
1. run attached Program.cs creating the binary file on .NET
2. run attached Program.cs creating the binary file on Mono
now recompile without #define create and swap binary files between systems
3. run the deserialization on both...
Actual Results:  
Exception is thrown on the deserialization on both Mono and .NET (just
different errors)

Expected Results:  
Even though the dictionary is empty, it should still deserialize the data
especially if the dictionary is part of a larger class.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list