Saturday, April 04, 2009

"Configuration system failed to initialize"

If you see a ConfigurationErrorsException along with the information "Configuration system failed to initialize" in your QuickWatch window then in all likelihood your app.config (or web.config) file is not correct. In my case I simply forgot to surround the membership provider section with <system.web></system.web>. Once I added those it worked like a breeze. Also, in case your custom provider cannot be found, make sure you have added the proper assembly name to the 'type' attribute for the <add> element of your provider in the <providers> section. And yes, you can test custom providers without having to deploy to or run in a web server. Just ensure your app.config file contains the bare minimum by copying some content from web.config and you should be fine. For my scenario it was sufficient to copy the config section for NHibernate, the hibernate configuration, and the declaration for my custom membership provider.

3 comments:

Anonymous said...

Config files drive me nuts sometimes. Visual Studio jumps all over me with every other kind of warning or error, but, heaven forbid you set a value to true instead of True and expect something like a compiler or intelicenseto validate this code you just wrote before 'compiling' an application. Config files seem like a cop-out in this regard. It would make since that the values aren't validated once the program is compiled, but this error...
Now I get to search the web for all the locations of all config files that could affect my app and review the syntax of each element and attribute in-hopes of finding some typo somewhere.

Anonymous said...

I got this problem after mistakenly creating a new settings file instead of using the default settings file found in the properties folder. After realizing my redundancy, I deleted the settings1 file, and everything seemed fine. But after a few compilations, I got the configuration system failed to initialize error. Upon analysis of my app.config file, I found a reference to the deleted settings1 class. I don't know why it worked for awhile before giving me this error, but it sure drove me nuts. I removed the line referring to settings1, and everything is all better.

Anonymous said...

I had the same issue when trying to reduce a webservice based application back to dotnet 2.0 in VisualStudio2008.

The solution did execute on my developer machine (3.5 installed) but did fail with

Configuration system failed to initialize
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(S
tring sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Intern
al.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sect
ionName)
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
at System.Diagnostics.TraceSource.Initialize()
at System.Diagnostics.TraceSource.get_Switch()
at System.Web.Services.Diagnostics.Tracing.InitializeLogging()
at System.Web.Services.Diagnostics.Tracing.get_On()
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at setInstanceAttribute.pids.PenInfoDeskServiceService..ctor()
at setInstanceAttribute.Program.Main(String[] args)


when executed in the target platform (no 3.5 installed).

After uncommenting the "system.serviceModel" section in the .config file, the application started and works.

Hope this helps someone, took me 8 hrs to figure this out :-(

Post a Comment

All comments, questions and other feedback is much appreciated. Thank you!