VB.NET 2.0 & Application Settings..

M

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
 
H

Herfried K. Wagner [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top