Hello!
I am trying to save MappedExe configuration file within user's AppData directory.
Problem occurs when I try to save encrypted connectionString.
This is the exception's message :
"System.Configuration.ConfigurationErrorsException: An error occured executing section handler for connectionStrings.-->System.Configuration.ConfigurationErrorsException: Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'. Error message from provider: Object already exists.
It only occurs with common users within domain, I have no problems with admins, power users, work-groups etc.
This is part of code responsible for saving configuration data:
if (_configuration.ConnectionStrings.ConnectionStrings[Application.ProductName] == null)
{
_configuration.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings(Application.ProductName,
_connStringBuilder.ToString()));
}
else
{
_configuration.ConnectionStrings.ConnectionStrings[Application.ProductName].ConnectionString = _connStringBuilder.ToString();
}
try
{
if (!_configuration.ConnectionStrings.SectionInformation.IsProtected)
{
_configuration.ConnectionStrings.SectionInformation.ForceSave = true;
_configuration.ConnectionStrings.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
}
_configuration.Save(ConfigurationSaveMode.Minimal);
}
catch (Exception ex)
{
#if DEBUG
MessageBox.Show(ex.ToString() + "\n" + ex.StackTrace);
#else
throw;
#endif
}
Can you help me?
P.S. This is a ClickOnce solution.