FederalProgrammer
Programmer
I have objA and define its serialization as shown below; This objA is an instance in another class, objB;
However, when I try to serialize objB, i get the error saying objA is not marked as serializable!!
What am I doing wrong... how do I make objA serializable!
=====================================================
public class objA
implements ISerializble
private _blah as string
Public Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements ISerializable.GetObjectData
info.AddValue("_blah", Me._blah)
info.SetType(GetType(callASerializationHelper))
End Sub
public property blah() as string
'normal property def'n here...
end property
end class
Friend Class sqlObjectSerialzationHelper
Implements IObjectReference, ISerializable
Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
' set the defaults
Dim s As New objA
' try to pull the data out
Try
s.blah = CType(info.GetValue("_blah", GetType(String)), String)
Catch ex As SerializationException
End Try
End Sub
Public Overridable Overloads Function GetRealObject(ByVal context As StreamingContext) As Object Implements IObjectReference.GetRealObject
Return New objA()
End Function
Public Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements ISerializable.GetObjectData
Throw New NotImplementedException()
End Sub
=====================================================
However, when I try to serialize objB, i get the error saying objA is not marked as serializable!!
What am I doing wrong... how do I make objA serializable!
=====================================================
public class objA
implements ISerializble
private _blah as string
Public Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements ISerializable.GetObjectData
info.AddValue("_blah", Me._blah)
info.SetType(GetType(callASerializationHelper))
End Sub
public property blah() as string
'normal property def'n here...
end property
end class
Friend Class sqlObjectSerialzationHelper
Implements IObjectReference, ISerializable
Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
' set the defaults
Dim s As New objA
' try to pull the data out
Try
s.blah = CType(info.GetValue("_blah", GetType(String)), String)
Catch ex As SerializationException
End Try
End Sub
Public Overridable Overloads Function GetRealObject(ByVal context As StreamingContext) As Object Implements IObjectReference.GetRealObject
Return New objA()
End Function
Public Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements ISerializable.GetObjectData
Throw New NotImplementedException()
End Sub
=====================================================