已经好几个月但我仍然不知道如何使用我的Windows窗体读取加密的app.config文件 .

我想知道的是:

我的WinForm应用程序如何读取加密的app.config文件?

它总是抛出这个异常

{"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened. (C:\Users\jsumgo\Documents\Visual Studio 2010\Projects\MIPIR\MIPIR\bin\Debug\MIPIR.vshost.exe.Config line 18)"}

我知道如何加密和解密app.config,但我的winform无法读取我的连接字符串的值 .

我使用 connectionmanager 来读取我的连接字符串

这是我如何阅读它们的代码

Public password As String = System.Configuration.ConfigurationManager.AppSettings("password")
Public userid As String = System.Configuration.ConfigurationManager.AppSettings("userid")
Public initcat As String = System.Configuration.ConfigurationManager.AppSettings("initcat")
Public dtsrc As String = System.Configuration.ConfigurationManager.AppSettings("dtsrc")

然后我将这些字符串构建到我的连接字符串中

我还想了解如何使用加密的app.config将此系统部署到我的客户端的过程 .

编辑:我仍然无法让RSA加密和读取我的连接字符串 .