S
solex
Hello,
I am trying to use serialization to copy objects. The object in question
"Institution" inherits from a parent object "Party" both are marked as
<Serializable()>. Initially I can copy an empty Institution to another
empty Institution, using the following routine:
Private Sub CopyObject(ByRef FromObject As Object, ByRef ToObject As Object)
Dim m As New MemoryStream
Dim b As New BinaryFormatter
b.Serialize(m, FromObject)
m.Position = 0
ToObject = b.Deserialize(m)
End Sub
I then populate some data into the copy and attempt to copy the object back
to the original. When doing so the following error is thrown:
An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in
mscorlib.dll
Additional information: The type myProject.EdtInstitution in Assembly
myProject, Version=1.0.1396.28005, Culture=neutral, PublicKeyToken=null is
not marked as serializable.
The interesting thing is that the object "myProject.EdtInstitution" in the
Assembly myProject is a form and is not being passed into the CopyObject
routine. Any suggestions on how to copy the object back?
Thanks,
Dan
I am trying to use serialization to copy objects. The object in question
"Institution" inherits from a parent object "Party" both are marked as
<Serializable()>. Initially I can copy an empty Institution to another
empty Institution, using the following routine:
Private Sub CopyObject(ByRef FromObject As Object, ByRef ToObject As Object)
Dim m As New MemoryStream
Dim b As New BinaryFormatter
b.Serialize(m, FromObject)
m.Position = 0
ToObject = b.Deserialize(m)
End Sub
I then populate some data into the copy and attempt to copy the object back
to the original. When doing so the following error is thrown:
An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in
mscorlib.dll
Additional information: The type myProject.EdtInstitution in Assembly
myProject, Version=1.0.1396.28005, Culture=neutral, PublicKeyToken=null is
not marked as serializable.
The interesting thing is that the object "myProject.EdtInstitution" in the
Assembly myProject is a form and is not being passed into the CopyObject
routine. Any suggestions on how to copy the object back?
Thanks,
Dan