By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,304 Members | 3,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,304 IT Pros & Developers. It's quick & easy.

Custom Application Settings

P: n/a
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

Jun 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

rob wrote:
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


Jun 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.