A procedure loops thru class' properties (via reflection) and sets them to values contained in a app.config file like this
foreach
(PropertyInfo property in type.GetProperties()){
if
(ConfigurationManager.AppSettings[property.name] != null){
value =
ConfigurationManager.AppSettings[property.name];}
}
However in two cases we've seen behaviour we can't explain. For example when property.name = "ValidState" ConfigurationManager.AppSettings[property.name] is NULL. But when I substitue property.name for "ValidState" then it works as expected. Another words:
(when property.name="ValidState")
ConfigurationManager.AppSettings[property.name] doesn't work but ConfigurationManager.AppSettings["ValidState"] works.
What could be the problem?
Replies
Know the answer? Post it — somebody with the same question will find it here.