Help with config file error
-
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.
-
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.
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:
-
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:
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
-
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
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:
-
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: