Configuration system failed to initialize - Help Please
When i try to run my app I get this exception "Configuration system failed to initialize"
I recently added a datascource to the app and am assuming that something has gone wrong there but it was all working ok and then this error just started.
I assume it's a problem with my appconfig file which i'll post here I cant see anything wrong with it but.!!
I've tried deleting the ConnectionString Section but nothing helps and i cant run my app at all!
Heeeeeelp!!
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="Bank.My.MySettings.AustralianConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Documents and Settings\Mike\Desktop\Bank dev\Current Accounts\Australian.mdb""
providerName="System.Data.OleDb" />
</connectionStrings>
<appsettings>
<add key="appname" value="Bank.exe" />
</appsettings>
</configuration>
[1074 byte] By [
Mikepy] at [2008-1-10]
I got this error earlier this evening 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.
Good luck!
Mike
Glad to hear that you solved your problem. Out of curiosity - did you try the Synchronize button in the settings designer? It will try & hunt down and delete any user.config files that may be out of sync/broken...
Best regards,
Johan Stenberg
It sounds like the .config file is broken at some level (most likely local user or roaming user). To locate the files, you can add the following to the constructor of your settings class (or in the settings property get:er that you modified to always return false).
Dim exeConfig As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None) Debug.WriteLine(exeConfig.FilePath)
Dim localConfig As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal) Debug.WriteLine(localConfig.FilePath)
Dim roamingConfig As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoaming) Debug.WriteLine(roamingConfig.FilePath)
This will print the location of the exe, local user and roaming user config files. Take a look in those files (if they exist) and look for any stray user scoped setting (you say that you don't have any user scoped settings, so unless any of the assemblies that you reference have user scoped settings, there shouldn't be any).
Let me know if this helps,
Johan Stenberg
Thanks, it worked. Somehow a user.config file from an old incarnation of the project had persisted and was intermittently wreaking havoc. Odd that the Synchronize button in the Settings Designer didn't find it, though.
It's good to hear that you managed to solve the problem.
The synchronize button in the settings designer tries as hard as it can to find all the files involved, but there are some things that it can't determine. In particular, two things that tend to make it confused is if you have click-once deployed or strong-named your executable. This is one area that we are looking to improve in the next version of Visual Studio.
Best regards,
Johan Stenberg
I'm getting a similar error; however, mine occurs whenever I add a reference to the System.configuration file in the references section of my project.
I'm trying to write to an app.config file using ConfigurationManager.AppSettings.Add and I may just not be doing things right, but the reference to the already existing non-tampered with setting seems to no longer exist after I added the System.configuration reference.
Anyone have any idea about this?
I have the same problem, but I am not sure why I am getting it. I tried displaying the exe Config, localConfig, roamingConfig and it displays nothing. I please do note that I am getting this error when I am trying to call the serviced component (.Net 2.0 code) method in ASP. Any ideas how I can fix this.
Thanks,
Kumarp
I was getting a similar error "Configuration system failed to initialize"
When I checked the error details it asked me to put <configSections> as the first section of <configuration> in app.config. I had put <appSettings> as the first element. I moved <configSections> on top and it worked fine for me.
Hope this helps.
Mohammed