Reputation: 9252
I have two ConfigurationElement objects (one of which is in the running application's app.config) and I need to replace that one with the other. I also have the ConfigurationElementCollection that the first element belongs to. It looks like the Add and Remove methods are protected internal. Is it not intended for me to be able to update the ConfigurationElementCollection object in runtime? If so, what are the alternatives?
Thanks.
Upvotes: 0
Views: 797
Reputation: 3013
ConfigurationElementCollection is an abstract class, so the concrete collection class might expose methods to add and remove.
However, when retrieved using the ConfigurationManager.GetSection method configuration is read only so even if the methods were accessible they would not work:
The GetSection method accesses run-time configuration information that it cannot change. To change the configuration, you use the GetSection method on the configuration file that you obtain by using one of the following Open methods:
What do you need to accomplish, and who is consuming that configuration? You might be able to change its behavior at a higher level rather than swapping the configuration information.
Upvotes: 2