在我的Windows应用程序,我试图加密app.config文件的连接字符串的部分,我的app.config文件的连接字符串的部分是使用提供者'RsaProtectedConfigurationProvider'解密失败?
<connectionStrings>
<add name="SQLiteDB" connectionString="Data Source=|DataDirectory|database.s3db;
Version=3;password=mypassword;" providerName="System.Data.Sqlite"/>
</connectionStrings>
和.cs文件我正在对它进行加密像
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
ConfigurationSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; // could be any section
if (!section.IsReadOnly())
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
运行此代码后,我得到加密的连接字符串在不同的app.config中,此app.config驻留在bin \ debug文件夹中,此.config文件的名称是nameofapplication.exe.config。
问题是,当我做了这个应用程序的设置,如果提示错误,其他计算机上运行:
System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.
我这样做第一次所以不知道如何解决这个问题,stucked在严重它。
仅供参考,或可能是约什导入的钥匙到其他机器上,在我的案件有关许可。当我在VS上进行调试时无法解密,但在以管理员身份打开VS之后。开始解密它。 – enterbutton 2018-02-07 23:12:56