[Mono-bugs] [Bug 77311][Nor] New - XmlSerializer fails to serialise generic dictionary

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jan 19 19:31:50 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by colin at breame.net.

http://bugzilla.ximian.com/show_bug.cgi?id=77311

--- shadow/77311	2006-01-19 19:31:50.000000000 -0500
+++ shadow/77311.tmp.4767	2006-01-19 19:31:50.000000000 -0500
@@ -0,0 +1,75 @@
+Bug#: 77311
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: colin at breame.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlSerializer fails to serialise generic dictionary
+
+Using XmlSerializer.Serialise on generic Dictionary (e.g. 
+Dictionary<string, string>) causes a spurious exception 
+(InvalidOperationException).  See below for a test program and the 
+exception I get when I run it.  Cheers! 
+ 
+Test program: 
+  
+using System.Collections.Generic;  
+using System.IO;  
+using System.Xml.Serialization;  
+  
+public class main_t {  
+  public static void Main() {  
+    Dictionary<string, string> test = new Dictionary<string, string>();  
+    StreamWriter writer = new StreamWriter("output");  
+  
+    XmlSerializer serialiser = new XmlSerializer(typeof(Dictionary<string,  
+                                                        string>));  
+    serialiser.Serialize(writer, test);  
+  }  
+}  
+ 
+Exception: 
+ 
+Unhandled Exception: System.InvalidOperationException: You must implement 
+a  
+default accessor on System.Collections.Generic.Dictionary`2
+[[System.String,  
+mscorlib, Version=2.0.0.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089], 
+[System.String, mscorlib, Version=2.0.0.0, Culture=neutral,  
+PublicKeyToken=b77a5c561934e089]] because it inherits from ICollection 
+in <0x001f7> System.Xml.Serialization.TypeData:get_ListItemType () 
+in <0x0001f> System.Xml.Serialization.TypeData:get_ListItemTypeData () 
+in <0x00145> System.Xml.Serialization.TypeData:.ctor (System.Type type,  
+System.String elementName, Boolean isPrimitive,  
+System.Xml.Serialization.TypeData mappedType,  
+System.Xml.Schema.XmlSchemaPatternFacet facet) 
+in <0x00019> System.Xml.Serialization.TypeData:.ctor (System.Type type,  
+System.String elementName, Boolean isPrimitive) 
+in <0x0032b> System.Xml.Serialization.TypeTranslator:GetTypeData 
+(System.Type  
+type, System.String xmlDataType) 
+in <0x0000c> System.Xml.Serialization.TypeTranslator:GetTypeData 
+(System.Type  
+type) 
+in <0x0005a> 
+System.Xml.Serialization.XmlReflectionImporter:ImportTypeMapping  
+(System.Type type, System.Xml.Serialization.XmlRootAttribute root,  
+System.String defaultNamespace) 
+in <0x0009d> System.Xml.Serialization.XmlSerializer:.ctor (System.Type 
+type,  
+System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[]  
+extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String  
+defaultNamespace) 
+in <0x00015> System.Xml.Serialization.XmlSerializer:.ctor (System.Type 
+type)


More information about the mono-bugs mailing list