Home All Groups Group Topic Archive Search About

VB.NET 2.0 & Application Settings..

Author
30 Jun 2006 2:48 PM
modi321
Everyone,

I have a question on how to use persistant application settings with
2.0.  I understand I can use defined types like ints, strings, and so
on, but how about my own custom class?  The problem is I can fill in
the 'type' of the setting as my custom class, but if I try to save the
settings - calling the My.Settings.Save() - then reload the settings at
a later time with the My.Settings.Reload() - the data in my custom
class is not there.  Infact I checked the XML and it only has the
setting's name.

In short:
1. Can I use my own class as a setting variable?
1.b.  If so, how?
2.  Do I need to use the Type converter?

http://msdn2.microsoft.com/en-us/library/a65txexh.aspx
"Application settings can be stored as any data type that is XML
serializable or has a TypeConverter that implements
ToString/FromString. The most common types are String, Integer, and
Boolean, but you can also store values as Color, Object, or as a
connection string."

3.  Is there a size restriction on the value of an application setting?
I wonder if my class exceeds this.

Thank you in advance,

Modi

Author
30 Jun 2006 11:55 PM
Herfried K. Wagner [MVP]
<modi***@gmail.com> schrieb:
> I have a question on how to use persistant application settings with
> 2.0.  I understand I can use defined types like ints, strings, and so
> on, but how about my own custom class?  The problem is I can fill in
> the 'type' of the setting as my custom class, but if I try to save the
> settings - calling the My.Settings.Save() - then reload the settings at
> a later time with the My.Settings.Reload() - the data in my custom
> class is not there.  Infact I checked the XML and it only has the
> setting's name.

Are you sure the settings are under the user scope and not the application
scope?  Note that settings with application scope are not saved by calling
the 'Save' method.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>