Answered Does the order of elements in app.config matter?

  • Thursday, July 21, 2011 6:17 PM
     
     

    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 there documentation that explictly exposes this behavior, an xsd schema maybe?

    • Moved by Andrew.Wu Friday, July 22, 2011 7:01 AM (From:.NET Framework Setup)
    •  

All Replies

  • Friday, July 22, 2011 7:01 AM
     
     

    Hi klingert,

    Since your question is more related with CLR, I'm going to move your post to the Common Language Runtime Forum for better support.

    Thanks for your understanding.

    Best Regards,


    Andrew Wu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Friday, July 22, 2011 12:23 PM
    Moderator
     
     Answered

    In general is shouldn't matter but some elements have special rules. It seem to be all documented. As example configSections has this specified.

    http://msdn.microsoft.com/en-us/library/ms228256.aspx

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

    I was hoping this would be the case with our link but it doesn't use external fille.

    Web.config in general

    http://msdn.microsoft.com/en-us/library/ms228147.aspx

    • Marked As Answer by klingert Friday, July 22, 2011 2:05 PM
    •