I use the XMLSerializer to serialise an object called SuperClass, and I get
something like this
<SuperClass>
<Classes>
<SomeName xsi:type="MyClass1">
</SomeName>
<SomeName xsi:type="MyClass2">
</SomeName>
<SomeName xsi:type="MyClass2">
</SomeName>
etc.
</Classes>
</SuperClass>
where SuperClass has a property that is a collection of type MyCollection.
The definition of the classes involved are
<code>
<Serializable()> _
Public Class MyCollection
Inherits Collections.CollectionBase
Public Sub Add(ByVal mcb As MyClassBase)
MyBase.List.Add(mcb)
End Sub
Default Public ReadOnly Property Item(ByVal Index As Integer) As
MyClassBase
Get
Return CType(MyBase.List.Item(Index), MyClassBase)
End Get
End Property
End Class
<Serializable(), _
XmlType("SomeName"), _
XmlInclude(GetType(MyClass1)), _
XmlInclude(GetType(MyClass2))> _
Public MustInherit Class MyClassBase
....
End Class
Public Class MyClass1
Inherits MyClassBase
End Class
Public Class MyClass2
Inherits MyClassBase
End Class
</code>
When I read it back (with handlers for the UnknownNode and UnknownAttribute
events) the UnknownNode event is fired.
Why would the serializer not be able to read back a file that it had
created? The odd thing is, if I change one of the elements in MyClass1, for
example, it is read in correctly, even though the serializer has complained
that it does not recognise the node.
TIA
Charles