Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com

Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

I have a section in Web.Config:

  <applicationSettings>

    <FSBsnsCsLib.Properties.Settings>

...

   </FSBsnsCsLib.Properties.Settings>

 </applicationSettings>

I've tried to access inner section using shortcut “Section/Subsection“

string sSectionName="applicationSettings/FSBusinessLib.My.MySettings";
System.Configuration.ClientSettingsSection sectSettings = (ClientSettingsSection)config.Sections[sSectionName];

but it returned null.

The correct way is the following:

const string cnstApplicationSection = "applicationSettings";
ConfigurationSectionGroup grpApplicationSection = config.SectionGroups[cnstApplicationSection];
string sSectionName="FSBusinessLib.My.MySettings";
System.Configuration.ClientSettingsSection sectSettings = grpApplicationSection .Sections[sSectionName];

This approach is used in my ConfigurationHelper class

Posted on Friday, May 12, 2006 8:08 AM .Net Framework , Deployment | Back to top


Comments on this post: Using Configuration.Section to access subsection

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net