|
-
Mar 9th, 2002, 04:49 PM
#1
Thread Starter
PowerPoster
Serialization of Collections
Back to this :P
I've noticed that when I try to serialize a Private Collection, I recieve no error -- it just doesn't save correctly. Now, I tried this:
VB Code:
<Serializable()> Public Class Test
Public R As New Collection()
Public M As String
End Class
Private Sub SaveSettings(ByRef mypath As String, ByRef myObject As Object)
Dim XmlS As XmlSerializer
Dim fStream As IO.FileStream
'Try
XmlS = New XmlSerializer(myObject.GetType)
fStream = New IO.FileStream(mypath, IO.FileMode.Create)
XmlS.Serialize(fStream, myObject)
fStream.Close()
End Sub
'CODE
Dim f As New Test()
f.R.Add("hi")
f.m = ":-)"
SaveSettings("C:\f.xml", f)
Which finally throws an error.
System.InvalidOperationException: There was an error reflecting 'MoW.Test'. ---> System.InvalidOperationException: You must implement the Add(System.Object) method on Microsoft.VisualBasic.Collection because it inherits from ICollection.
What does this mean?
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Mar 10th, 2002, 07:59 AM
#2
Lively Member
When a class implements the ICollection interface it must include an Add method and Item property to be Serializable.
-
Mar 10th, 2002, 10:35 AM
#3
Thread Starter
PowerPoster
Right...so how would I go about doing that?
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Mar 10th, 2002, 11:30 AM
#4
Lively Member
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemxmlserializationxmlserializerclasstopic.htm
-
Mar 10th, 2002, 11:44 AM
#5
Thread Starter
PowerPoster
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|