Custom Type for Application Settings

  • Thread starter Thread starter Mark Olbert
  • Start date Start date
M

Mark Olbert

You can browse for a Type to use as the basis of an application setting (at least under VS2005/NET2)...but how do you define your
own custom Type so that it can be used as the basis of an application setting?

I would like to be able to hold a collection of MyClass objects (via a List<MyClass>) in the application settings.

- Mark
 
Hi Mark,
I would like to be able to hold a collection of MyClass objects (via a
List<MyClass>) in the application settings.

If you mean to do this via code, not in the VS2005 IDE's UI wizard (Project
| Properties | Settings tab page), then there are two approaches you can
choose.

1. Implement the TypeConverter to your custom type.
2. Define your custom type as XML serializable.

I suggest you can refer to the following MSDN documentations for the
detailed information about the above workarounds:

How to: Implement a Type Converter
http://msdn2.microsoft.com/en-us/library/ayybcxe5(VS.80).aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemxmlserializationxmlserializerclasstopic.asp

If you have any issues or concerns, please let me know. It's my pleasure to
be of assistance.

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Gary,

I'm familiar with implementing both TypeConverters and marking classes as XmlSerializable. How does doing either let the class show
up in the VS2005 UI for setting properties?

- Mark
 
Mark said:
Gary,

I'm familiar with implementing both TypeConverters and marking
classes as XmlSerializable. How does doing either let the class show
up in the VS2005 UI for setting properties?

It doesn't. The application settings facility in VS2005 is rather flawed,
and not really finished. The types that are present in the settings editor
when you first opened it are in fact the only types that will work.

See

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=FDBK30022

for more.

-cd
 
Carl,

Thanks for the info. Now at least I won't waste time trying to do something that currently can't be done.

Having had to implement a design-time Type resolver for a database framework I wrote, I can appreciate how complex that type of
solution is.

- Mark
 
Back
Top