I am developing a Windows desktop application with C # .NET4.0 VS2010 on Windows 8.1. I have a number of settings that I store using the .NET settings mechanism. They have a user scope, so when they are installed in the application, they are written to "Users \ username \ AppData \ Local \ companyname \ App.exe_URL_randomstuff \ versionno \ user.config.
These options include some user registration information that I need to hide. My research shows that I should be able to encrypt settings with RsaProtectedConfigurationProvider, but all the examples I found for this relate to app.config encryption, not user.config (like http://msdn.microsoft.com/ en-us / library / system.configuration.rsaprotectedconfigurationprovider.aspx ).
My question, therefore, can be encrypted by user.config, and if so, how? I note that when I instantiate a System.Configuration.Configuration object, I can set ConfigurationUserLevel to PerUserRoamingAndLocal. When I check the object through the debugger, it seems to refer to the correct user.config file, but when I go to the instance, the ConfigurationSection returns null to protect it. The code is as follows:
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.PerUserRoamingAndLocal); ConfigurationSection connStrings = config.AppSettings; connStrings.SectionInformation.ProtectSection(provider);
I think config.AppSettings is probably incorrect, but I'm not sure what to replace it with.
Any advice was greatly appreciated.
source share