Hi,
We have a XSD given by a third party. We are basically attempting to convert
this into a class, using XSD.exe, then populating the members of the class
from a database and then serialise the class into xml and send that across.
The "MessageBody" element (in the XSD) is a choice element and contains
0..multiple other elements and when it gets serialised into a class it looks
like this
[System.Xml.Serialization.XmlRootAttribute(Namespac e="", IsNullable=false)]
public class MessageBody
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Pers on", typeof(Person))]
[System.Xml.Serialization.XmlElementAttribute("Fina ncials",
typeof(Financials))]
[System.Xml.Serialization.XmlElementAttribute("Empl oyment",
typeof(Employment))]
public object[] Items;
For a single object like Financials, I get the Finance data object and add
it to an array list and then say Class.MessageBody =
(object[])myArrayList.ToArray(typeof(object))
The problem is that it is supposed to accept multiple Person objects but
when I try to add in a Person[] it throws InvalidOperationExceptions.
There is no problem with the Person objects per-se because I can add in
Person[0] into the array list and then into the object[].
Any ideas?
Thanks in advance,
Santosh