[Mono-bugs] [Bug 527199] New: inary serialization between .NET and Mono fails with Dictionary with an Enum key

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jul 31 12:03:32 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=527199


           Summary: inary serialization between .NET and Mono fails with
                    Dictionary with an Enum key
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jxelam at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:

An object containing a dictionary with a key type of enum cannot be serialized
on Mono and deserialized on .NET and vice versa.

Steps to reproduce the problem:
1. Compile file below
2. Run with "client" as arg to serialize (using Mono)
3. Run with "server" as arg to deserialzie (using .NET)

using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;

namespace SerializeFail {
    class SerializeFail {
        static void Main(string[] args) {
            if (args.Length == 0 || args[0].Equals("client")) {
                TestClass test = new TestClass();
                test.testDict.Add(MyEnum.TEST, "ing");  

                FileStream fs = File.Create("data.bin");
                BinaryFormatter formatter = new BinaryFormatter();

                formatter.Serialize(fs, test);
            }

            else if (args[0].Equals("server")) {
                FileStream fs = File.OpenRead("data.bin");
                BinaryFormatter formatter = new BinaryFormatter();

                TestClass test = (TestClass)formatter.Deserialize(fs);
                Console.WriteLine("Data: " + test.testDict[MyEnum.TEST]);
            }
        }
    }

    [Serializable]
    public class TestClass {
        public Dictionary<MyEnum, string> testDict = new Dictionary<MyEnum,
string>(); 
    }

    public enum MyEnum {
        TEST
    }
}

Actual Results:

When deserialized on .NET: 

System.InvalidCastException: Object must implement IConvertible.

When deserialised on Mono:

System.Runtime.Serialization.SerializationException: Could
not find type 'System.Collections.Generic.ObjectEqualityComparer`1[[SerializeFa
l.MyEnum, SerializeFail, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]
'.

Expected Results:

True sent to stdout

-- 
Configure bugmail: http://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