我有一个对配置文件中的部分进行加密的应用程序。当我第一次尝试从配置文件中读取加密部分时,我收到一条错误消息:“无法识别的属性‘configProtectionProvider’。请注意,属性名称区分大小写。”
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Get the section in the file.
ConfigurationSection section = config.GetSection("EncryptedSection");
if (section != null)
{
// Protect the section.
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;
// Save the change.
config.Save(ConfigurationSaveMode.Modified);
}
ConfigurationManager.RefreshSection("EncryptedSection");
Properties.Settings.Default.Reset();
//This is the part where I read the encrypted section:
ConfigurationManager.RefreshSection("EncryptedSection");
System.Collections.IDictionary HSMMasterKeyConfig = (System.Collections.IDictionary)System.Configuration.ConfigurationManager.GetSection("EncryptedSection");
这种情况仅发生在我第一次尝试读取加密部分时。我注意到 .config 文件在第一次保存后立即更新,但由于某种原因我需要重新启动应用程序才能使用加密部分。
你读过这篇文章吗...
http://bytes.com/groups/net/521818-configurationerrorexception-when-reading-protected-config-section http://bytes.com/groups/net/521818-configurationerrorexception-when-reading-protected-config-section
...因为这似乎是涉及 MSFT 支持工程师的对话,直接反映了您的情况。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)