Hello, I have a singleton settings class (.Net 2.0 framework) that I
serialize/deserialize to XML. On my settings class is a shared list of
integers. If I have two numbers in my list and I deserialize my class
successive times, the count of integers in my list grows by 2 each time when
I would expect it to remain at 2. When I run this code (below) and click the
button multiple times, my immediate window shows the following results:
2
4
6
8
10
Can anyone tell me what's going on here? TIA.
Imports System.Xml.Seri alization
<Serializable() _
Public Class cMySettings
Public Shared UserIDs As List(Of Integer)
Public Property zUserIDs() As List(Of Integer)
Get
Return UserIDs
End Get
Set(ByVal value As List(Of Integer))
UserIDs = value
End Set
End Property
End Class
Public Class Form1
Private Const sXML As String = _
"<?xml version=""1.0"" encoding=""utf-16""?<cMySettin gs" & _
"<zUserIDs><int >1</int><int>2</int></zUserIDs></cMySettings>"
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim myStream As New System.IO.Strin gReader(sXML)
Dim serializer As New
System.Xml.Seri alization.XmlSe rializer(GetTyp e(cMySettings))
serializer.Dese rialize(myStrea m)
Debug.Print(cMy Settings.UserID s.Count)
End Sub
End Class
serialize/deserialize to XML. On my settings class is a shared list of
integers. If I have two numbers in my list and I deserialize my class
successive times, the count of integers in my list grows by 2 each time when
I would expect it to remain at 2. When I run this code (below) and click the
button multiple times, my immediate window shows the following results:
2
4
6
8
10
Can anyone tell me what's going on here? TIA.
Imports System.Xml.Seri alization
<Serializable() _
Public Class cMySettings
Public Shared UserIDs As List(Of Integer)
Public Property zUserIDs() As List(Of Integer)
Get
Return UserIDs
End Get
Set(ByVal value As List(Of Integer))
UserIDs = value
End Set
End Property
End Class
Public Class Form1
Private Const sXML As String = _
"<?xml version=""1.0"" encoding=""utf-16""?<cMySettin gs" & _
"<zUserIDs><int >1</int><int>2</int></zUserIDs></cMySettings>"
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim myStream As New System.IO.Strin gReader(sXML)
Dim serializer As New
System.Xml.Seri alization.XmlSe rializer(GetTyp e(cMySettings))
serializer.Dese rialize(myStrea m)
Debug.Print(cMy Settings.UserID s.Count)
End Sub
End Class
Comment