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.XmlTextWriter(Path.Combine(Application.Startup Path, "GoodFiles.xml"), System.Text.Encoding.UTF8)
Dim xs As New Xml.Serialization.XmlSerializer(GetType(clsGoodFil es)) <=== ERROR LINE
Dim obj As New clsGoodFiles()
obj.Add("ABC.TIF", "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.InvalidOperationException' occurred in system.xml.dll
Additional information: There was an error reflecting 'WindowsApplication22.clsGoodFiles'.
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