Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the order of elements in app.config matter?

I have seen and experienced problems with app.config/web.config where I had changed the order of elements and the app stopped working. I believe I fixed the problem by looking at machine.config and following the order in there.

One example is the following question: Common.Logging config exception

The issue was resolved by changing the order the elements appear in the file.

So, the question is, does the order of elements matter?

It appears to me it does. If it does, is it documented anywhere, an xsd schema maybe?
like image 688
Klinger Avatar asked Jul 21 '11 17:07

Klinger


People also ask

Can we have multiple app config?

You cannot use multiple configuration files (i.e. one per library project) without coding.

Is app config the same as web config?

Web. Config is used for asp.net web projects / web services. App. Config is used for Windows Forms, Windows Services, Console Apps and WPF applications.

How does app config work?

App. Config is an XML file that is used as a configuration file for your application. In other words, you store inside it any setting that you may want to change without having to change code (and recompiling). It is often used to store connection strings.

Where should app config be located?

The application configuration file usually lives in the same directory as your application. For web applications, it is named Web. config. For non-web applications, it starts life with the name of App.


1 Answers

It appears that at least for the configSections element order does matter.

Document http://msdn.microsoft.com/en-us/library/ms228256.aspx states the following:

"If the configSections element is in a configuration file, the configSections element must be the first child element of the configuration element."

I got this from here: http://social.msdn.microsoft.com/Forums/en-US/clr/thread/60c7b502-f7fc-49e9-b4b0-771b4fb4134e

like image 194
Klinger Avatar answered Oct 18 '22 16:10

Klinger