P
Peter
Hi,
If I Serialized a instance of class zCMethod and then deserialized it, no
error occurs.
Now ,I Serialized a instance of class InheritedCMethod and then deserialized
it, I got an error.
system: MissingMemberException: FieldInfo can't match destination type¡£
I know the error appears only because I have defined a array Geometry(). But
I do need the array,how to deal with it?
Thanks in advance,
Peter
Below is my code:
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.binary
Imports System.Data.OleDb
<Serializable()> Public Class zCMethod
public Name as string
Public Specimen As Specimens
Protected mSubType As Short
Sub New()
Specimen.Initialize()
End Sub
<Serializable()> Structure Specimens
Dim Geometry() As Single
Public Sub Initialize()
ReDim Geometry(9)
End Sub
End Structure
End Class
<Serializable()> Public Class InheritedCMethod
Inherits zCMethod
Sub New( ByVal iSubType As Short)
MyBase.new()
msubtype = iSubType
End Sub
Public Sub SerializeMethod()
If File.Exists("MyMethod.bin") Then File.Delete("MyMethod.bin")
Dim Formatter As New BinaryFormatter
Dim Stream As New FileStream("MyMethod.bin", FileMode.Create, _
FileAccess.Write, FileShare.None)
Formatter.Serialize(Stream, Me)
Stream.Close()
End Sub
Public Sub DeserializeMethod()
If System.IO.File.Exists("MyMethod.bin") Then
Dim Formatter As New BinaryFormatter
Dim streamRead As New FileStream("MyMethod.bin",
FileMode.Open, _
FileAccess.Read,
FileShare.Read)
Formatter.Deserialize(streamRead)
streamRead.Close()
End If
End Sub
End Class
sub Main
Dim zMethod As InheritedCMethod = New InheritedCMethod(0)
zMethod.SerializeMethod()
zMethod.DeserializeMethod()
end sub
If I Serialized a instance of class zCMethod and then deserialized it, no
error occurs.
Now ,I Serialized a instance of class InheritedCMethod and then deserialized
it, I got an error.
system: MissingMemberException: FieldInfo can't match destination type¡£
I know the error appears only because I have defined a array Geometry(). But
I do need the array,how to deal with it?
Thanks in advance,
Peter
Below is my code:
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.binary
Imports System.Data.OleDb
<Serializable()> Public Class zCMethod
public Name as string
Public Specimen As Specimens
Protected mSubType As Short
Sub New()
Specimen.Initialize()
End Sub
<Serializable()> Structure Specimens
Dim Geometry() As Single
Public Sub Initialize()
ReDim Geometry(9)
End Sub
End Structure
End Class
<Serializable()> Public Class InheritedCMethod
Inherits zCMethod
Sub New( ByVal iSubType As Short)
MyBase.new()
msubtype = iSubType
End Sub
Public Sub SerializeMethod()
If File.Exists("MyMethod.bin") Then File.Delete("MyMethod.bin")
Dim Formatter As New BinaryFormatter
Dim Stream As New FileStream("MyMethod.bin", FileMode.Create, _
FileAccess.Write, FileShare.None)
Formatter.Serialize(Stream, Me)
Stream.Close()
End Sub
Public Sub DeserializeMethod()
If System.IO.File.Exists("MyMethod.bin") Then
Dim Formatter As New BinaryFormatter
Dim streamRead As New FileStream("MyMethod.bin",
FileMode.Open, _
FileAccess.Read,
FileShare.Read)
Formatter.Deserialize(streamRead)
streamRead.Close()
End If
End Sub
End Class
sub Main
Dim zMethod As InheritedCMethod = New InheritedCMethod(0)
zMethod.SerializeMethod()
zMethod.DeserializeMethod()
end sub