Please help me
I am getting RsaProtectedConfigurationProvider not found error
using System.Configuration;
public
static void Encrypt()
{
//Create a new ExeConfigurationFileMap
ConfigurationFileMap oFile = new ConfigurationFileMap();
//ExeConfigurationFileMap oFile = new ExeConfigurationFileMap();
////Precise its path
oFile.MachineConfigFilename =
@"C:\Encryption\web.config";
string provider = "RsaProtectedConfigurationProvider";
//Create a new configuration object related to the configuration file
Configuration Config = ConfigurationManager.OpenMappedMachineConfiguration(oFile);
//Create a section and set it as the targeted section
ConfigurationSection constrings = Config.Sections.Get("connectionStrings");
//oSection = oConfiguration.GetSection("connectionStrings") as ConnectionStringsSection;
//if the section is already encrypted dont ecrypt it again
if (constrings != null && !constrings.SectionInformation.IsProtected)
{
if (!constrings.ElementInformation.IsLocked)
{
//if (!oSection.SectionInformation.IsProtected)
//{
//The section ecryption
constrings.SectionInformation.ProtectSection(provider);
//Update the configuration file
Config.Save();
MessageBox.Show("Connection string encrypted");
//}
}
}
}