Hi,
I am using a SoapFormatter to serialize a class which has a member that is
derived from DictionaryBase.
Everything works fine... I can serialize and deserialize. The trouble I
have is that I need to implement versioning, so I have to implement the
ISerializable interface and provide the GetObjectData function and the
constructor to deserialize the object. When I try to deserialize the member
that is derived from DictionaryBase, I get an empty object.
Here is some sample code:
<Serializable()> _
Public Class clsSimpleDictionary
Inherits DictionaryBase
'
' I have removed all the code just to be concise
'
End Class
<Serializable()> _
Public Class SerializedSettings
Implements ISerializable
Public m_SMTPServer As String
Public m_AddressBook As clsSimpleDictionary
Public Sub New()
m_AddressBook = New clsSimpleDictionary
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As
StreamingContext)
Try
m_SMTPServer = info.GetString("m_SMTPServer")
'
' This is the offending line
'
m_AddressBook = info.GetValue("m_AddressBook",
GetType(clsSimpleDictionary))
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
Private Sub GetObjectData(ByVal info As SerializationInfo, ByVal context
As StreamingContext)
Implements ISerializable.GetObjectData
info.AddValue("m_SMTPServer", m_SMTPServer, m_SMTPServer.GetType())
info.AddValue("m_AddressBook", m_AddressBook,
m_AddressBook.GetType())
End Sub
End Class
If I don't implement ISerializable, the SoapFormatter will serialize and
deserialize the clsSimpleDictionary member fine.
Can somebody please point me in the right direction.
TIA
Allan