XmlSerializer and collections

  • Thread starter Thread starter Sebastian Sylvan
  • Start date Start date
S

Sebastian Sylvan

Hello.
I'm trying to serialize an object using the XML-serializer. A simple
object is okay, But when I try to serialize an object which has a public
List<SomeType> the program hangs upon calling the XmlSerializer constructor.

I have verified that everything in the object is okay (not null). I've
tried to give the list a type of IEnumerable instead of List<T> but that
didn't work either.

I'm using the Visual C# Express Beta.

Any ideas?
 
Wes said:
Hello Sebastian,

Try adding [XmlInclude(typeof(SomeType))] to the class you are are trying to serialize, where SomeType is the type of the item you have in your collection.

Thanks, that did the trick!

/S
 
Back
Top