static void Main()
{
//other code
// Protect the Connection Strings
ProtectConfiguration();
Application.Run(new MainForm());
}
static void ProtectConfiguration()
{
// TODO: Protect the Connection Strings
string provider = "RsaProtectedConfigurationProvider";
Configuration config = null;
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.ConnectionStrings;
if ((section.SectionInformation.IsProtected == false) &&
(section.ElementInformation.IsLocked == false))
{
// Protect (encrypt) the "connectionStrings" section.
section.SectionInformation.ProtectSection(provider);
// Save the encrypted section.
section.SectionInformation.ForceSave = true;
config.Save( ConfigurationSaveMode.Full);
}
}
After I successfully run this window application, the app.config connection string section was not encrypted.
How would I do that works
.NET Development7
|