(E-Mail Removed) wrote:
<snip>
>I create an ArrayList, add the class to the ArrayList and try to call
>XmlSerializer.Serialiaze(myArrayList);
>
>i recieve this error:
>The type Card
>was not expected.
>Use the XmlInclude or SoapInclude
>attribute to specify types that are not known statically
>
>what else do i have to add to my Card class so that it will work
You need to use the XmlInclude attribute on the collection class, not on
the object class. I think you can also use it on a property that has the
collection type, but I'm not completely sure. So, this might work:
class MyClass {
private ArrayList list;
[XmlInclude(typeof(Card))]
public ArrayList List {
get { return list; }
set { list = value; }
}
}
And I'm sure it will work if your derive your own collection type from
CollectionBase (in .NET 1, I think things are different in .NET 2 when
using a List<Card>) and put the attribute on the collection class.
Finally I should say, why didn't you post this to dotnet.xml?
Oliver Sturm
--
Expert programming and consulting services available
See
http://www.sturmnet.org (try /blog as well)