sunburnt
Mar 9th, 2002, 03:49 PM
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:
<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?
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:
<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?