We help IT Professionals succeed at work.

Configuration System Failed to Initialize

Hawkeye6352
Hawkeye6352 asked
on
I have the following config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="DLLLoadTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
  <!-- Configuration section-handler declaration area. -->
  <configSections>
    <sectionGroup name="serverControlGroup">
      <section
        name ="serverControl"
        type = "ADMultiDomain.ServerControlSections"
        allowLocation = "true"
        allowDefinition = "Everywhere"
        />
    </sectionGroup>
  </configSections>
  <!-- Configuration section-handler declaration area -->
  <serverControlGroup>
    <serverControl controlKey = "1" controlName = "MurachWebControlLibrary.dll" description = "Server Control Test"
                   location = "C:\LOCAL_DEVELOPMENT\MurachWebControlLibrary\MurachWebControlLibrary\obj\Debug\"
                   method = "DaysUntilDate" />
  </serverControlGroup>

  <applicationSettings>
        <DLLLoadTest.Properties.Settings>
            <setting name="General" serializeAs="String">
                <value>"No value, used to generate app.config in proper format"</value>
            </setting>
        </DLLLoadTest.Properties.Settings>
    </applicationSettings>
</configuration>

And I am using the following to intialize my class to read from the app.config:

                DLLLoadTest.ServerControlSections config =
                    (DLLLoadTest.ServerControlSections)System.Configuration.ConfigurationManager.GetSection("serverControlGroup/serverControl");

And I get the following error, when this code tries to execute:

'Configuration System failed to initialize'

Any thoughts why.  I made sure that under the root I have configSections.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Why do you have two <configSections> entries?

Author

Commented:
Would that be causing the problem?  I will combine them and see what happens. Thanks.
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
I believe so. If you inspect the InnerException of the exception that is raised, it should give you an indication of what's going wrong.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.