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

Creating A Configuration Settings Object

P: n/a
Apr 9 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a

P: n/a
Hi J,

As for creating custom configuration section for .NET framework application
configuration file, you have two means according to the .net framework 2.0
configuration section handler interface:

1. Use the existing configuration classes to build your custom
comfigurationSection in a declarative way.

#How to: Create Custom Configuration Sections Using ConfigurationSection
http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx

http://www.codeproject.com/dotnet/cu...ctionsNet2.asp
2. Using built-in classes may have few customzation ability such as control
the exact element name or collection section's child elements. thus, you
can also build a custom section through complete programmatic way by using
the IConfigurationSectionHandler interface:

#How to: Create Custom Configuration Sections Using
IConfigurationSectionHandler
http://msdn2.microsoft.com/en-us/library/ms228056.aspx

in this case, you will write all the code that do the xml reading/writing
for your custom section

Here is a list of all those .NET 2.0 configuration section classes you can
use:

#Classes Used to Create Custom Section Handlers
http://msdn2.microsoft.com/en-us/lib...62(vs.80).aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Apr 10 '07 #3

P: n/a
For the most part, the built in stuff is working for me. The one thing that
i would like is to be able to have config sections within sections...

So I can reference settings like such:

My.Settings.Setting1
My.Settings.Setting2
My.Settings.Category1.Setting1
My.Settings.Category2.Setting2

Is there a way to have this sort of hierarchical settings configuration with
the built in stuff?

Thanks.

J
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:jD**************@TK2MSFTNGHUB02.phx.gbl...
Hi J,

As for creating custom configuration section for .NET framework
application
configuration file, you have two means according to the .net framework 2.0
configuration section handler interface:

1. Use the existing configuration classes to build your custom
comfigurationSection in a declarative way.

#How to: Create Custom Configuration Sections Using ConfigurationSection
http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx

http://www.codeproject.com/dotnet/cu...ctionsNet2.asp
2. Using built-in classes may have few customzation ability such as
control
the exact element name or collection section's child elements. thus, you
can also build a custom section through complete programmatic way by using
the IConfigurationSectionHandler interface:

#How to: Create Custom Configuration Sections Using
IConfigurationSectionHandler
http://msdn2.microsoft.com/en-us/library/ms228056.aspx

in this case, you will write all the code that do the xml reading/writing
for your custom section

Here is a list of all those .NET 2.0 configuration section classes you can
use:

#Classes Used to Create Custom Section Handlers
http://msdn2.microsoft.com/en-us/lib...62(vs.80).aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.


Apr 11 '07 #4

P: n/a
Thanks for your reply J,

As for the hierarchical setting you mentioned, here is my understanding:

the .NET framework configuration system can only support the following
section/group hierarchy:

* a certain section directly under the <configurationroot
* a certain section under a section group(like <system.web>) and other
sections nested under that section group

so far I haven't found any reference about nested sections in other
sections.

As for the My.Settings.Category2.Setting2 like section, one way to
achive this setting structure is a below:

* create a custom section, this is the "My"

* in "My" configuration section, define "Settings" as a sub property(of
ConfigurationElement derived type)

* in "Settings" configuration Element you define "Category2" as a sub
property

* in "Category2" configuration Element class, you define "Setting2" as a
sub property

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.