Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

marking an item as serializable

Status
Not open for further replies.

FederalProgrammer

Programmer
Joined
Jul 2, 2003
Messages
318
Location
CA
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
=====================================================

 
it's pretty damn easy:
I don't need to implement serialization for objA; all I have to do is this:

<serializable()> public class objA
end class

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top