I'm using VB.NET 2002 on Windows 2000 Pro and am having trouble serializing a SortedList.
This is my class:
<Serializable() Public Class clsGoodFiles
Inherits SortedList
Public Sub New()
MyBase.New()
End Sub
End Class
This is my calling code:
Dim xw As New Xml.XmlTextWrit er(Path.Combine (Application.St artupPath, "GoodFiles.xml" ), System.Text.Enc oding.UTF8)
Dim xs As New Xml.Serializati on.XmlSerialize r(GetType(clsGo odFiles)) <=== ERROR LINE
Dim obj As New clsGoodFiles()
obj.Add("ABC.TI F", "A")
xs.Serialize(xw , obj)
xw.Close()
xw = Nothing
xs = Nothing
GC.Collect()
When it gets to the line indicated as ERROR LINE, it generates the following error:
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.xml.dll
Additional information: There was an error reflecting 'WindowsApplica tion22.clsGoodF iles'.
This same technique works fine if I inherit an ArrayList. But ArrayList and SortedList both show Serializable in the documentation. Is there a way to get the serialization of the SortedList to work? Thanks.
Phil
This is my class:
<Serializable() Public Class clsGoodFiles
Inherits SortedList
Public Sub New()
MyBase.New()
End Sub
End Class
This is my calling code:
Dim xw As New Xml.XmlTextWrit er(Path.Combine (Application.St artupPath, "GoodFiles.xml" ), System.Text.Enc oding.UTF8)
Dim xs As New Xml.Serializati on.XmlSerialize r(GetType(clsGo odFiles)) <=== ERROR LINE
Dim obj As New clsGoodFiles()
obj.Add("ABC.TI F", "A")
xs.Serialize(xw , obj)
xw.Close()
xw = Nothing
xs = Nothing
GC.Collect()
When it gets to the line indicated as ERROR LINE, it generates the following error:
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.xml.dll
Additional information: There was an error reflecting 'WindowsApplica tion22.clsGoodF iles'.
This same technique works fine if I inherit an ArrayList. But ArrayList and SortedList both show Serializable in the documentation. Is there a way to get the serialization of the SortedList to work? Thanks.
Phil
Comment