Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Reading config files

The CLR will ignore an invalid config file (invalid XML). If the app does have an invalid config file and you try to query for an AppSetting the CLR will throw a ConfigurationException. Consider wrapping queries into your config file with a try catch block. Its quite possible someone can modify the config file without your knowledge and leave it in an invalid state.

2 Comments

  • Hmm if someone's modified my config file without my knowledge I think I'd prefer an uncaught exception.

  • I'll just add to Me's comment - if somebody is able to modify your config files what's going to stop them from modifying your code [to remove the exception handling]?

Comments have been disabled for this content.