Hi TheCow,
You need to declare the type of the objects stored inside the ArrayList in
order for the XmlSerializer to process it properly. You can declare the
types by attaching XmlElement or XmlArrayItem attributes with the Type
property set to the types in the ArrayList to the ArrayList field:
public class foo
{
[XmlElement( Type=(typeof(baz) )]
public ArrayList bar;
}
or you can pass them to the constructor of the XmlSerializer:
XmlSerializer ser = new XmlSerializer( typeof( foo ), new Type[] { typeof
( baz ) } );
HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
You can do that either via the XmlInclude attribute
"TheCow" <co*@cow.cow> wrote in message
news:bh**********@news.net.uni-c.dk...
Hi Group
I have homemade class, lets call it firstclass, and then another class
(secondclass) which contains an ArrayList of firstclass objects.
When I try to xml serialize secondclass with the arraylist in it I get an
errormessage saying "The type <TheNameSpace>.<TheFirstClass> was not
expected. Use the XmlInclude or SoapInclude attribute to specify types
that are not known statically."
I dont have the slightest clue about what to do here, and I can't find
anything on the web about it.
..TheCow