>Notice: if I replace the items added to the
>arraylist (sub load) with strings instead of
>objects, the serialization works.  Why does
>serialization work with an arraylist of strings and
>not objects?

The XML Serializer knows what a string is.  It does not know what your objects are.  
Especially in an ArrayList because it just holds objects.  You have to tell the 
serializer what "extra" types to expect.  You do this by passing in an array of types 
that your root type uses (in your case the ArrayItem class).  Or you can us a strongly 
typed implementation of ICollection.

I guess it could be argued that the serializer could go that next step and use 
reflection to figure out the type.  But today it makes you specify the types so that 
it doesn't have to guess which ones you want and which ones you don't.

Just for closure, the following should work for you (C# syntax...sorry...don't have 
VB.NET engrained in my head yet)

Type[]extra = new Type[]{ typeof(ArrayItem) };
new XmlSerializer(typeof(DataHolder), extra);

If that doesn't work, I'll dig up a sample I have that is similar to the question you 
ask and I'll post it.

Justin

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to