2

I'm trying to save the following class to the user.config and I'm not sure what I'm doing wrong. Is the dictionary object not allowing the class to be serialized?

<Serializable()>Public Class RunInformation
    Public ExecutablePath As String
    <NonSerialized()> Public Settings As Dictionary(Of String, String)
    <NonSerialized()> Public ProcessId As Integer
    <NonSerialized()> Public Handle As IntPtr
    <NonSerialized()> Public TabPageHandle As IntPtr

    Public Sub New()
        ExecutablePath = ""
        Settings =  New Dictionary(Of String, String)
    End Sub
End Class

Saving:

Private Sub Form1_Closing(sender As Object, e As EventArgs) Handles MyBase.Closing
    my.Settings.Setting = New RunInformation()
    My.Settings.Save()
End Sub

XML File:

<userSettings>
    <BotManager.My.MySettings>
        <setting name="Setting" serializeAs="Xml">
            <value />
        </setting>
    </BotManager.My.MySettings>
</userSettings>
chancity
  • 31
  • 2

1 Answers1

0

The problem is that your serializing the info as XML but using the binary serialization control attributes.

Use the attribute System.Xml.Serialization.XmlIgnore instead

FloatingKiwi
  • 4,408
  • 1
  • 17
  • 41