Can't xml serialize type of [,]

Hi,

Im using class XMLSerializer to serialize my class that includes a field of type Object. This field can be any type i want.

In order to be able to serialize and deserialize my object i wrote class named ObjectSerializer that handles all types, here is the class:

public class ObjectSerializer: IXmlSerializable {

#region Constructors
public ObjectSerializer() {}

public ObjectSerializer(Object Data) {
this.Data= Data;
}
#endregion Constructors

#region Properties
public Object Data{
get { return Data; }
} Object Data;
#endregion Properties

#region IXmlSerializable Implementation
public XmlSchema GetSchema() {
return null;
}

public void ReadXml(XmlReader reader) {
Type type = Type.GetType(reader.GetAttribute("type"));
reader.ReadStartElement();
this.Data= (Object) new
XmlSerializer(type).Deserialize(reader);
reader.ReadEndElement();
}

public void WriteXml(XmlWriter writer) {
writer.WriteAttributeString("type", Data.GetType().ToString());
new XmlSerializer(parameters.GetType()).Serialize(writer, Data);
}
#endregion IXmlSerializable Implementation

}

My problem showed up when Data was of type Byte[,]. I also noticed that MSDN notes that XMLSerializer class cant serialize type ArrayList and List.

So how can i xml serialize type [,]




Answer this question

Can't xml serialize type of [,]

  • Can't xml serialize type of [,]