Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:54:56+00:00 2026-05-27T22:54:56+00:00

In .NET configuration, you can write your own configuration section and have quite a

  • 0

In .NET configuration, you can write your own configuration section and have quite a lot of freedom in how to structure it (as XML). So in most cases we do this:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="MySection" type="MySectionType, MySectionAssembly" ... />
    </configSections>

    <MySection>
        ...
    </MySection>
</configuration>

Then, to access our section in code, we do the following:

MySection mySection = (MySection) ConfigurationManager.GetSection("MySection");

The example above is the only way I’ve seen to have a custom section obtained in code.

Imagine now that we have a library or framework, that defines the MySection classes and the classes for the structure inside it. We want to provide these classes and structure to a third party developers that will define in their applications the configuration files. At the same time, our framework will need to obtain that section programmatically in order to function properly.

Clearly, the end user of our framework has the absolute freedom to name MySection to anything else. Therefore the code above will fail to load the section. Is there a nice way to overcome this issue? Deciding to force the consumers of the library to name their section only in the way we desire is something I would like to avoid doing.

EDIT:
An additional complication to the scenario is putting the section in a section group:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="MyGroup">
            <section name="MySection" type="MySectionType, MySectionAssembly" ... />
        </sectionGroup>
    </configSections>

    <MyGroup>
        <MySection>
            ...
        </MySection>
    </MyGroup>
</configuration>

Would it be possible to handle this situation too?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:54:57+00:00Added an answer on May 27, 2026 at 10:54 pm

    Should not be a problem. See this:

    http://msdn.microsoft.com/en-us/library/system.configuration.configurationsectiongroup.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the .net configuration tool in windows 7 but can
How do I change my user's password with the ASP.NET configuration Tool? I can't
I'm searching the XSD (XML Schema) for the Microsoft .NET application configuration files. Till
I have a COM Component DLL. I can use this DLL in VB.NET. But
I have a Windows (not Web) NET 1.1 app which can accept the settings
Question We have a large number of xml configuration files that we want merged
The .NET 2.0 and up configuration system is quite powerful and extensible - as
I have recently used Visual Basic .Net to write a particle system which emits
I have a ASP.NET MVC application for which I want to write some stress
The part of my Coherence tangosol-coherence-override.xml configuration doesn't work. I can start up the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.