vb.net – App.config连接字符串保护错误

前端之家收集整理的这篇文章主要介绍了vb.net – App.config连接字符串保护错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我遇到了以前的问题;找不到我如何解决它的参考.

这是问题所在.我们使用以下代码为客户端应用程序加密app.config中的连接字符串部分:

config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
        If config.ConnectionStrings.SectionInformation.IsProtected = False Then
            config.ConnectionStrings.SectionInformation.ProtectSection(Nothing)

            ' We must save the changes to the configuration file.'
            config.Save(ConfigurationSaveMode.Modified,True)
        End If

问题是我们有一个营业员休假.旧的笔记本电脑将转到新的销售人员,并在新用户登录下,当它试图这样做时,我们得到一个错误.错误是:

Unhandled Exception: System.Configuration.ConfigurationErrorsException: 
An error occurred executing the configuration section handler for connectionStrings. ---> System.Configuration.ConfigurationErrorsException: Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'. 
Error message from the provider: Object already exists.
---> System.Security.Cryptography.CryptographicException: Object already exists
我找到了一个更优雅的解决方案,在我对自己的原始回答中.我发现如果我刚刚以root用户身份登录,并且安装了应用程序并导致配置文件连接字符串被加密并在commadn提示符下转到.net framework目录并运行
aspnet_regiis -pa "NetFrameworkConfigurationKey" "{domain}\{user}"

它授予其他用户访问RSA加密密钥容器的权限,然后它适用于其他用户.

我只是想在这里添加它,因为我认为我已经在我们的开发博客上发布了这个问题,但是在这里找到它,所以如果我需要再次查找它将会在这里.将在此主题添加指向我们的开发博客点的链接.

原文链接:https://www.f2er.com/vb/255893.html

猜你在找的VB相关文章