PC Review


Reply
Thread Tools Rate Thread

Custom Application Settings

 
 
rob
Guest
Posts: n/a
 
      23rd Jun 2006
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

 
Reply With Quote
 
 
 
 
rob
Guest
Posts: n/a
 
      23rd Jun 2006
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with storing a custom type in application settings michael sorens Microsoft C# .NET 15 16th Jan 2008 02:44 AM
Custom Application Settings rob Microsoft Dot NET Framework Forms 1 23rd Jun 2006 06:13 PM
Custom Type for Application Settings Mark Olbert Microsoft Dot NET Framework 4 11th Apr 2006 07:04 AM
Custom Type under Application Settings =?Utf-8?B?Y29kZTNfYnJlbnQ=?= Microsoft Dot NET 0 30th Dec 2005 06:25 PM
'current custom error settings for application prevent details of application error from being viewed. ' Damian Microsoft ASP .NET 3 30th Dec 2003 08:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 AM.