[Mono-list] XmlInclude/XmlSerializer troubles, any workaround?
Steven Brown
swbrown@ucsd.edu
Fri, 22 Aug 2003 22:01:52 -0700
To use XmlSerializer to serialize objects containing other untyped
objects, csc requires an [XmlInclude] attribute (as far as I know), but
it seems mono's XmlSerializer hasn't gotten to the point where it can
understand it (or is this a previously unknown issue?). Is there a way
around this problem for now anyone can reccomend? Here's a testcase
that throws with mono and passes with MS:
using System;
using System.Collections;
using System.Xml.Serialization;
public class Contained {
}
[XmlInclude(typeof(Contained))]
public class Container {
public ArrayList contained = new ArrayList();
}
class Test {
public static void Main(string[] args) {
XmlSerializer serializer = new XmlSerializer(typeof(Container));
Container container = new Container();
container.contained.Add(new Contained());
serializer.Serialize(Console.Out, container);
}
}