My.Settings won't serialize my class
-
I was wondering if you can add a custom class to the My.Settings object. I mean I know you can because I did, but the problem I'm having is the class won't persist ie. the data isn't saved. The only requirment (I thought) was that the object needed to be serializable, which mine is. So am I doing something wrong, or is this just not an option. I looked for a while but just couldn't find an answer or an example. Also as a general rule, if there even is one, what kind of data should I save using the my.settings object? Should I just stick with basics like form location and color settings or is it appropriate to store whatever you want as long as you wish to store it in an xml format? Here is a very simple class I made for testing.
<Serializable()> _
Public Class TestClass
Public Name As StringPublic Sub New(ByVal name As String) Me.Name = name End Sub
End Class
This is the code I used to extend My.Settings object.
Namespace My
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase\_ Public Property MyTestClass() As TestClass Get Return CType(Me("MyTestClass"), TestClass) End Get Set(ByVal value As TestClass) Me("MyTestClass") = value End Set End Property End Class
End Namespace