Custom Application Settings

  • Thread starter Thread starter rob
  • Start date Start date
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
 
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
 
Back
Top