In the MS .NET framework isn't this by design? Can't serialize a Dictionary? I think some have used IXMLSerializable as a workaround.
-Dan Maltes -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gert Driesen Sent: Thursday, January 19, 2006 2:53 PM To: 'Colin JN Breame'; mono-list@lists.ximian.com Subject: RE: [Mono-list] XmlSerializer with Dictionary Hi Colin, I'm looking into fixing quite some (compatibility) issues in XmlSerializer (and XmlSchemaExporter, XmlReflectionImporter, SoapReflectionImporter, ...). Please submit a bug report for this and feel free to assign it to me. Gert > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Colin JN > Breame > Sent: woensdag 18 januari 2006 22:32 > To: mono-list@lists.ximian.com > Subject: [Mono-list] XmlSerializer with Dictionary > > Hello, > > When I try to xml serialise a generic dictionary (e.g. > Dictionary<string,string>), I get the exception: > > System.InvalidOperationException: You must implement a default > accessor on System.Collections.Generic.Dictionary`2[snip] because it > inherits from ICollection > > This looks like it could be a bug but then again I'm not even sure it > is possible to serialise a generic dictionary. Any pointers would be > appreciated. > > Cheers, > Colin > > > 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) > > > > > > _______________________________________________ > Mono-list maillist - Mono-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-list > _______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list _______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list