Cannot encrypt connectionstrings in winforms but works in web?mmm Can you help
Cannot understand why this works in a web (changing to WebConfigManager) but not in a winapp.When I go a look at the config file is still not encrypted!!Am I missing something? Can You help?
 EncryptionUtility.ProtectSection("connectionStrings", "DataProtectionConfigurationProvider");
public class EncryptionUtility
    {
        public static void ProtectSection(string sectionName,string pro开发者_JAVA百科vider)
        {
            var config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
            var section = config.GetSection(sectionName);
            if (section == null || section.SectionInformation.IsProtected) return;
            section.SectionInformation.ProtectSection(provider);
            config.Save();
        }
        public  static void UnProtectSection(string sectionName)
        {
            var config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
            var section = config.GetSection(sectionName);
            if (section == null || !section.SectionInformation.IsProtected) return;
            section.SectionInformation.UnprotectSection();
            config.Save();
        }
    }
In winforms you have 3 config files: one in the project, on in the debug directory and one in release directory. Are you sure you trying to encrypt the right one?
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论