6
Konsol uygulamasının App.config dosyasındaki appSettings
ve connectionStrings
bölümünü şifrelemeye çalışıyorum. Bazı nedenlerden dolayı section.SectionInformation.IsProtected
her zaman doğrudur.App.config dosyasındaki Korunan Bölüm Konsol Uygulaması
static void Main(string[] args)
{
EncryptSection("connectionStrings", "DataProtectionConfigurationProvider");
}
private static void EncryptSection(string sectionName, string providerName)
{
string assemblyPath = Assembly.GetExecutingAssembly().Location;
Configuration config = ConfigurationManager.OpenExeConfiguration(assemblyPath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(providerName);
config.Save();
}
}
Neden her zaman doğru döndüğünden emin değilsiniz.