The dreaded “Configuration system failed to initialize”


So has this ever Happened to you (if not then you’re lucky…) :

 

System.Configuration.ConfigurationErrorsException was unhandled Message=”Configuration
system failed to initialize”

BareMessage=”Configuration system failed to
initialize”

I’ve discovered that the worst VS Error response is the one where the message has nothing to do with the actual error!!!
And I will walk throught debugging this problem with you. Sure there are many references
out there saying make sure your <configSections /> block is the first thing inside your empty *.config
file:

Like this Not Like this

<?xmlversion=1.0encoding=utf-8 ?>

<configuration>

     <configSections/>

    <appSettings />

</configuration>

<?xmlversion=1.0encoding=utf-8 ?>

<configuration>

     <appSettings />

     <configSections/>

</configuration

 

 

Well that was o.k. now what do You or I do if your still
getting the wonderfully descriptive, “Configuration system failed to initialize”?

Well, I spent more hours consulting
The Google
and… after hunting down that link… I found something, the
config
file wasn’t getting copied to the correct file with the
build, so I went into Properties->Copy Always.. and still Nothing…. So I’m looking at the Build as I try
some things and I see a few build warnings.. I cleaned
those up.. and wait for it…
Nothing…

I learned that if you have :

<?xmlversion=1.0encoding=utf-8 ?>

<configuration>

 

<configSections>

                            <sectionname=bobotype=clown/>

                            <sectionname=bobotype=dog/>

               </configSections>

</configuration>

The Config Reader will only see
“bobo” as a dog…
But that doesn’t really help me… And so I continued my quest into the
neathers of C# config sections… I was hopefull about a post concerning
renaming.. only to see that I haven’t changed the name… so no dice there. I opened up my application.exe.config
file and noticed that it was an old version so I deleted it and rebuilt.. still
nothing…(the rebuilt one was the same as the old one.. ) Ahh HA… now to just figure
out how this happens.. o.k. it’s time to go to sleep I made “progress”.

Ultimatly I solved this problem by starting a new solution and importing all the
files into this solution, and discarding the old one. In the end I believe it
boils down to an out of synch issue in my subversion. (Ank svn).

I hope this helps you.

Advertisements

About Larry Louisiana

I'm a Microsoft Partner Consultant.
This entry was posted in Programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s