P
Paul
Hi All.
We have a custom class which we serialize. This class is regularly updated, and the old requests do not have a problem opening, apart from a couple!!! When it try's to deserialize the class I receive "One of the serialized keys is null". I tried to change the constructor "below" to check if the object is null to change is to a new object and set the value but still have the same error. Any ideas? as we need to keep backward compatibly.
Private Sub New(ByVal Info As SerializationInfo, ByVal Context As StreamingContext)
On Error Resume Next
Dim fieldValue As Object = Nothing
Dim i As Int32
Dim thisType As Type = Me.GetType()
Dim mi As MemberInfo() = FormatterServices.GetSerializableMembers(thisType, Context)
For i = 0 To mi.Length - 1
Dim fi As FieldInfo = mi(i)
fieldValue = Nothing
fieldValue = Info.GetValue(fi.Name, fi.FieldType)
If (Not fieldValue Is Nothing) Then fi.SetValue(Me, fieldValue)
Next
We have a custom class which we serialize. This class is regularly updated, and the old requests do not have a problem opening, apart from a couple!!! When it try's to deserialize the class I receive "One of the serialized keys is null". I tried to change the constructor "below" to check if the object is null to change is to a new object and set the value but still have the same error. Any ideas? as we need to keep backward compatibly.
Private Sub New(ByVal Info As SerializationInfo, ByVal Context As StreamingContext)
On Error Resume Next
Dim fieldValue As Object = Nothing
Dim i As Int32
Dim thisType As Type = Me.GetType()
Dim mi As MemberInfo() = FormatterServices.GetSerializableMembers(thisType, Context)
For i = 0 To mi.Length - 1
Dim fi As FieldInfo = mi(i)
fieldValue = Nothing
fieldValue = Info.GetValue(fi.Name, fi.FieldType)
If (Not fieldValue Is Nothing) Then fi.SetValue(Me, fieldValue)
Next