I found the following code to set the readonly attribute to false for the ConfigurationManager.ConnectionStrings property:
typeof(ConfigurationElementCollection)
.GetField("bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(ConfigurationManager.ConnectionStrings, false);
Is it possible to apply this to make the AppSettings property also editable?
AppSettings is a NameValueCollection which implements NameObjectCollectionBase which has the IsReadOnly property on it. However if I call GetFields() it returns an empty list.
Aucun commentaire:
Enregistrer un commentaire