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 pathoFile.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 ecryptionconstrings.SectionInformation.ProtectSection(provider);
//Update the configuration fileConfig.Save();
MessageBox.Show("Connection string encrypted"); //}}
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.