Custom Application Settings

R

rob

Using the settings editor I am trying to add a setting whose type is a
custom type. In a first approach I tried a class marked as
[Serializable]. But then when I try to get the property the way shown
bellow I get null returned.

MyProperties prop = Properties.Settings.Default.MyProp

Assuming prop is null because MyProperties is not a value type I
changed MyProperties from a class to a struct. Unfortunately, settings
editor does not allow me to add a struct giving me the following error:

"There was an error generating the xml document"

Can a value type not be serialized or what is going on here?

In any case, how can I add custom types to the application settings?

Thanks
 
R

rob

It seems that for the class case the return value is null because
nothing has been stored yet and therefore the type cannot be
deserialized. That poses the question why not just a new object is
created with the default constructor instead of returning null? Also
how do I get the struct case working?

Thanks
 

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