G
Guest
Hi,
I'm having trouble getting XML serialization to work correctly -- I'd
appreciate any help.
To learn this I've got a class I'm going to serialize:
Public Class SerializeThis1
Dim mName As String
Dim mBDay As Date
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal Value As String)
mName = Value
End Set
End Property
Public Property BDay() As Date
Get
Return mBDay
End Get
Set(ByVal Value As Date)
mBDay = Value
End Set
End Property
End Class
I try to serialize it like this:
Imports System.IO
Imports System.Xml.Serialization
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub uxSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles uxSave.Click
Dim mClass As New SerializeThis1
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(SerializeThis1))
mClass.Name = Me.uxName.Text
mClass.BDay = Me.uxBDay.Text
Dim writer As TextWriter
writer = New StreamWriter("SerializationTest.xml")
serializer.Serialize(writer, mClass)
MessageBox.Show("done")
writer.Close()
End Sub
End Class
I wind up with this error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll
Additional information: File or assembly name 2ada-ph5.dll, or one of its
dependencies, was not found.
The editor has the following line highlighted:
serializer = New XmlSerializer(GetType(SerializeThis1))
If I try to use my instantiation:
serializer = New XmlSerializer(GetType(mClass))
I wind up with a message (as I'm typing) saying mClass isn't defined.
Obviously I'm not understanding a whole bunch of things. I've tried looking
at examples, and going through help, but I seem to be getting nowhere fast.
I'd appreciate any help.
Thanks,
Art
I'm having trouble getting XML serialization to work correctly -- I'd
appreciate any help.
To learn this I've got a class I'm going to serialize:
Public Class SerializeThis1
Dim mName As String
Dim mBDay As Date
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal Value As String)
mName = Value
End Set
End Property
Public Property BDay() As Date
Get
Return mBDay
End Get
Set(ByVal Value As Date)
mBDay = Value
End Set
End Property
End Class
I try to serialize it like this:
Imports System.IO
Imports System.Xml.Serialization
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub uxSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles uxSave.Click
Dim mClass As New SerializeThis1
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(SerializeThis1))
mClass.Name = Me.uxName.Text
mClass.BDay = Me.uxBDay.Text
Dim writer As TextWriter
writer = New StreamWriter("SerializationTest.xml")
serializer.Serialize(writer, mClass)
MessageBox.Show("done")
writer.Close()
End Sub
End Class
I wind up with this error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll
Additional information: File or assembly name 2ada-ph5.dll, or one of its
dependencies, was not found.
The editor has the following line highlighted:
serializer = New XmlSerializer(GetType(SerializeThis1))
If I try to use my instantiation:
serializer = New XmlSerializer(GetType(mClass))
I wind up with a message (as I'm typing) saying mClass isn't defined.
Obviously I'm not understanding a whole bunch of things. I've tried looking
at examples, and going through help, but I seem to be getting nowhere fast.
I'd appreciate any help.
Thanks,
Art