在安装程序期间,我们运行此方法来加密 app.config 的部分:
// Get the application configuration file.
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Define the Rsa provider name.
const string provider = "RsaProtectedConfigurationProvider";
// Get the section to protect.
ConfigurationSection connStrings = config.ConnectionStrings;
if (connStrings != null)
{
if (!connStrings.SectionInformation.IsProtected)
{
if (!connStrings.ElementInformation.IsLocked)
{
// Protect the section.
connStrings.SectionInformation.ProtectSection(provider);
connStrings.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
}
到目前为止工作正常。但是,如果我运行此程序,我们会在多台计算机上遇到以下错误“无法使用提供程序‘RsaProtectedConfigurationProvider’解密。来自提供程序的错误消息:无法打开 RSA 密钥容器".
当然我搜索并发现这个帮助,但这不起作用。有任何想法吗?
我在 Win 7 上的 Visual Studio 2010 中进行调试时遇到了类似的问题,并将 UAC 设置为默认保护。
为了解决这个问题,我必须以管理员身份运行 Visual Studio(“以管理员身份运行”)。
我在尝试运行 aspnet_regiis.exe 来加密 web.config 部分时遇到了同样的问题。如果我没有“以管理员身份”运行命令行/控制台,我会收到一个更神秘的命令行错误:“对象已存在”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)