In the dotNET configuration files you can add items to a collection like appSettings with
<appSettings> <add key="" value=""/> </appSettings>
Because this is XML you can also use the following line to add an item:
<appSettings> <add key="" value=""></add> </appSettings>
But not the same for clearing the list. Try adding <clear></clear> to the top of your appSettings section and you likely get the exception “Unrecognized element ‘add'”.
According to Tess Ferrandez the workaround is so simple that Microsoft is not going to fix it.
Using reflector on the dotNET 2.0 system.configuration assembly I saw some strange code. Look at the OnDeserializeUnrecognizedElement of System.Configuration.ConfigurationElementCollection and in there you’ll see this part of code:
... while (reader.MoveToNextAttribute()) { string name = reader.Name; throw new ConfigurationErrorsException(SR.GetString("Config_base_unrecognized_attribute", new object[] { name }), reader); } ...
Reading this made me realize that the following xml will work, because there is no “unrecognized” tag after the closing clear tag.
<appSettings> <clear></clear> </appSettings>
So be safe and always use <clear/> in config files. Because this behavior affects all configuration. Remember this the next time you add a AuthorizationPolicy.