I've stepped through my code and all seems to be working. I'm taking two values from an async response and I'm trying to write it to my appSettings
in app.Config
however....when I force refresh of my app.config, there are no values there at all.
Code for getting and writing values to app.config
is
public void Authenticated(Action success, Action<Exception> failure)
{
Client.GetAccessTokenAsync((accessToken) =>
{
UserToken = accessToken.Token;
UserSecret = accessToken.Secret;
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = config.AppSettings.Settings;
if (settings["userLoginSecret"] == null && settings["userLoginToken"] == null)
{
settings.Add("userLoginSecret", UserSecret);
settings.Add("userLoginToken", UserToken);
}
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);
if (success != null) success();
},
(error) =>
{
if (failure != null) failure(error);
});
}
And my app.Config
file is staying like this:
<appSettings>
<add key="userLoginToken" value=""/>
<add key="userLoginSecret" value=""/>
</appSettings>`
Any help much appreciated....