https://bugzilla.novell.com/show_bug.cgi?id=685042
https://bugzilla.novell.com/show_bug.cgi?id=685042#c0 Summary: Thrown exception when serializing a class that implements from IDictionary using DataContract Classification: Mono Product: Mono: Class Libraries Version: 2.6.x Platform: All OS/Version: All Status: NEW Severity: Major Priority: P5 - None Component: WCF AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.10 (maverick) Firefox/3.6.16 If a class is implementing IDictionary (and possibly other ICollection classes), attempts at serializing the data with a DataConstruct serializer it will throw an exception or plain not work. The exception is below. Unhandled Exception: System.Runtime.Serialization.SerializationException: There was an error during serialization for object of type AIR.Collections.EventDictionary`2[System.String,System.String] ---> System.ArgumentException: method arguments are incompatible at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) [0x00349] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/corlib/System/Delegate.cs:264 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/corlib/System/Delegate.cs:273 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/corlib/System/Delegate.cs:278 at System.Reflection.MonoProperty.CreateGetterDelegate (System.Reflection.MethodInfo method) [0x00068] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/corlib/System.Reflection/MonoProperty.cs:287 at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00058] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/corlib/System.Reflection/MonoProperty.cs:304 at System.Runtime.Serialization.Json.TypeMapProperty.GetMemberOf (System.Object owner) [0x00000] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs:297 at System.Runtime.Serialization.Json.TypeMap.Serialize (System.Runtime.Serialization.Json.JsonSerializationWriter outputter, System.Object graph, System.String type) [0x00023] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs:180 at System.Runtime.Serialization.Json.JsonSerializationWriter.WriteObjectContent (System.Object graph, Boolean top, Boolean outputTypeName) [0x004bc] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationWriter.cs:146 at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObjectContent (System.Xml.XmlWriter writer, System.Object graph) [0x00000] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs:243 at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.Xml.XmlWriter writer, System.Object graph) [0x00008] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs:208 --- End of inner exception stack trace --- at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.Xml.XmlWriter writer, System.Object graph) [0x00023] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs:215 at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00000] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs:221 at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.IO.Stream stream, System.Object graph) [0x00007] in /home/ntomsic/Downloads/build/mono-2.10.1/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs:201 at AIR.MainClass.Main (System.String[] args) [0x00028] in /home/ntomsic/Projects/AIR/AIR/Main.cs:38 This happens on all releases. Reproducible: Always Steps to Reproduce: 1. Create a generic class that inherits from IDictionary<TKey, TValue> public class MyDictionary<TKey, TValue> : IDictionary<TKey, TValue> { ... } 2. In main class, create a MyDictionary object, add an element, and serialize. using System; using System.IO; using System.Runtime.Serialization.Json; public class MainClass { public static void Main(string[] args) { MyDictionary<string, string> dict = new MyDictionary<string, string>(); dict.Add("key", "value"); var serializer = new DataContractJsonSerializer(dict.GetType()); var stream = new MemoryStream(); serializer.WriteObject(stream, dict); stream.Position = 0; var reader = new StreamReader(stream); Console.WriteLine(reader.ReadToEnd()); } } 3. Compile and run. Actual Results: Running gives the exception above. Expected Results: [{"Key":"key","Value":"value"}] This works on Windows with .NET. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
