Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help with config file error

Help with config file error

Scheduled Pinned Locked Moved C#
helpquestionvisual-studioworkspace
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ttohme
    wrote on last edited by
    #1

    I have an app.config file that looks like this: This use to work fine in VS 2003, when I migrated to VS 2005 I started getting this error : " Configuration system failed to initialize" "Sections must only appear once per config file" Anyone knows how can I fix this??? Thanks in advance.

    S 1 Reply Last reply
    0
    • T ttohme

      I have an app.config file that looks like this: This use to work fine in VS 2003, when I migrated to VS 2005 I started getting this error : " Configuration system failed to initialize" "Sections must only appear once per config file" Anyone knows how can I fix this??? Thanks in advance.

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      ttohme wrote:

      " Configuration system failed to initialize"

      when I changed the settings available in My.Settings - what I found in my case was that one of the changes I had made had added a StringCollection and it needed a try-catch block to create a new instance the first time around if it didn't exist. That, plus I had corrupted the user.config file.... when I deleted that it wrote a new one and started working fine.

      ttohme wrote:

      "Sections must only appear once per config file"

      To get your code to compile without the warnings, you'll need to replace your call to System.Configuration.ConfigurationSettings.GetConfig("systems") with System.Configuration.ConfigurationManager.GetSection("systems") This new type lives in the System.Configuration.dll assembly so you'll also need to add a reference to this assembly to your project. To migrate your v1.1 configuration section handler to v2.0, you'll need to re-write your sectionHandler using the new Configuration system base classes which live in the System.Configuration namespace in the System.Configuration.dll assembly. You'll need to use the following classes: ConfigurationSection, ConfigurationElement and ConfigurationElementCollection. Here's a pretty good link that blogs how to create your own sectionHandler: Get it[^]

      Regards, Satips.:rose:

      T 1 Reply Last reply
      0
      • S Sathesh Sakthivel

        ttohme wrote:

        " Configuration system failed to initialize"

        when I changed the settings available in My.Settings - what I found in my case was that one of the changes I had made had added a StringCollection and it needed a try-catch block to create a new instance the first time around if it didn't exist. That, plus I had corrupted the user.config file.... when I deleted that it wrote a new one and started working fine.

        ttohme wrote:

        "Sections must only appear once per config file"

        To get your code to compile without the warnings, you'll need to replace your call to System.Configuration.ConfigurationSettings.GetConfig("systems") with System.Configuration.ConfigurationManager.GetSection("systems") This new type lives in the System.Configuration.dll assembly so you'll also need to add a reference to this assembly to your project. To migrate your v1.1 configuration section handler to v2.0, you'll need to re-write your sectionHandler using the new Configuration system base classes which live in the System.Configuration namespace in the System.Configuration.dll assembly. You'll need to use the following classes: ConfigurationSection, ConfigurationElement and ConfigurationElementCollection. Here's a pretty good link that blogs how to create your own sectionHandler: Get it[^]

        Regards, Satips.:rose:

        T Offline
        T Offline
        ttohme
        wrote on last edited by
        #3

        I'm not getting compile errors, I did switch to using ConfigurationManager. My problem, is that in the old config file I referenced multiple config file in the app.config which means I could access other projects config file setting in the main application, now VS 2005 is complaining the having multiple sections is not allowed. I need to know how can I modify my config file so it can still reference multiple configuration files. Thanks

        S 1 Reply Last reply
        0
        • T ttohme

          I'm not getting compile errors, I did switch to using ConfigurationManager. My problem, is that in the old config file I referenced multiple config file in the app.config which means I could access other projects config file setting in the main application, now VS 2005 is complaining the having multiple sections is not allowed. I need to know how can I modify my config file so it can still reference multiple configuration files. Thanks

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          ttohme wrote:

          now VS 2005 is complaining the having multiple sections is not allowed.

          Yes.

          ttohme wrote:

          I need to know how can I modify my config file so it can still reference multiple configuration files.

          Please modify the config file into a single config file and run your application.

          Regards, Satips.:rose:

          T 1 Reply Last reply
          0
          • S Sathesh Sakthivel

            ttohme wrote:

            now VS 2005 is complaining the having multiple sections is not allowed.

            Yes.

            ttohme wrote:

            I need to know how can I modify my config file so it can still reference multiple configuration files.

            Please modify the config file into a single config file and run your application.

            Regards, Satips.:rose:

            T Offline
            T Offline
            ttohme
            wrote on last edited by
            #5

            Thanks for your help I appreciate it. Can you tell me how to modify my config file into a single config using the config file in my post? Are you suggesting I copy all the settings from the other config files into the app.config? Thanks again

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups