Where is my settings variables saved ?
-
Hi, I have created some settings file other than the main Settings.settings within my C# Win project. Before I used to see that, all new varaibles of all other settings files are being saved in the app.config file as an serializable XML. But in the past few days, I faced a problem with Configuration manager and I used to get error message "Configuration manager failed to load". After hassling for a while I found that, once I changed my project folder's name, the "Configuration manager error gone." but Now, I dont see the new variables in the app.config file any more. yet the settings vars are being saved in my computer somehow somewhere... I dont have any idea where are they being saved. I am worrid thinking that, if I ship my software to my client's pc, will it work in the same way by saving the settings variable somewhere in the PC without saving in app.config ? Thanks and regards Emran
-
Hi, I have created some settings file other than the main Settings.settings within my C# Win project. Before I used to see that, all new varaibles of all other settings files are being saved in the app.config file as an serializable XML. But in the past few days, I faced a problem with Configuration manager and I used to get error message "Configuration manager failed to load". After hassling for a while I found that, once I changed my project folder's name, the "Configuration manager error gone." but Now, I dont see the new variables in the app.config file any more. yet the settings vars are being saved in my computer somehow somewhere... I dont have any idea where are they being saved. I am worrid thinking that, if I ship my software to my client's pc, will it work in the same way by saving the settings variable somewhere in the PC without saving in app.config ? Thanks and regards Emran
-
Hi, I have created some settings file other than the main Settings.settings within my C# Win project. Before I used to see that, all new varaibles of all other settings files are being saved in the app.config file as an serializable XML. But in the past few days, I faced a problem with Configuration manager and I used to get error message "Configuration manager failed to load". After hassling for a while I found that, once I changed my project folder's name, the "Configuration manager error gone." but Now, I dont see the new variables in the app.config file any more. yet the settings vars are being saved in my computer somehow somewhere... I dont have any idea where are they being saved. I am worrid thinking that, if I ship my software to my client's pc, will it work in the same way by saving the settings variable somewhere in the PC without saving in app.config ? Thanks and regards Emran
Application setting persistence is thorougly described in "Application Settings Architecture" MSDN article (http://msdn2.microsoft.com/en-us/library/8eyb2ct1(VS.80).aspx), though, to say in short, they are stored in two parts: application-scope settings are stored in app.exe.config file that should be in the application folder, user-scope settings are stored in local user profile %InstallRoot%\Documents and Settings\username\Local Settings\Application data\CompanyName\ProductName\ProductVersion. The key thing is that this storage depends not only on product-name but on product build either. So, if you will leave apllication build number as it is set by default (1.0.*) or will change build number yourself location will change after build and your settings will be lost because they automatically migrate only when you use ClickOnce application deployment. Therefore you have to create your own settings migration mechanism or your own custom provider for settings storage to control your settings completely.
-
Application setting persistence is thorougly described in "Application Settings Architecture" MSDN article (http://msdn2.microsoft.com/en-us/library/8eyb2ct1(VS.80).aspx), though, to say in short, they are stored in two parts: application-scope settings are stored in app.exe.config file that should be in the application folder, user-scope settings are stored in local user profile %InstallRoot%\Documents and Settings\username\Local Settings\Application data\CompanyName\ProductName\ProductVersion. The key thing is that this storage depends not only on product-name but on product build either. So, if you will leave apllication build number as it is set by default (1.0.*) or will change build number yourself location will change after build and your settings will be lost because they automatically migrate only when you use ClickOnce application deployment. Therefore you have to create your own settings migration mechanism or your own custom provider for settings storage to control your settings completely.
Hi, Thanks for your reply. I have gone thru the article you provided (MSDN) and I realized that the User Scope application settings are stored in the User's profile path returned by System.Windows.Forms.Application.LocalUserAppDataPath. Now, it will be an issue to pack this item into a single installer as I am not using "click Once", how can I instruct my application to load and save user scoped settings.config file in the same Application.StartupPath ? Regards emran
-
Hi, Thanks for your reply. I have gone thru the article you provided (MSDN) and I realized that the User Scope application settings are stored in the User's profile path returned by System.Windows.Forms.Application.LocalUserAppDataPath. Now, it will be an issue to pack this item into a single installer as I am not using "click Once", how can I instruct my application to load and save user scoped settings.config file in the same Application.StartupPath ? Regards emran
Well, I'm afraid I cannot be much help to you. I can say that LocalFileSettingsProvider is a bit of a tough job after I looked through its source. It can be reproduced of course but there is a hell lot of work to do. To be honest I use standard application settings only for a small stuff like window positions - even if they are lost it doesn't make much trouble and can be replaced by reasonable defaults. As for serious things, global settings that persist from version to version and all that I use the same strategy as with common data files - I simply choose the convenient location and put my settings there using simple Dictionary object to store them and serialize/deserialize manually with somthing like SoapFormatter. After all ApplicationSettingsBase is a simple dictionary wrapper too. Regards, Oleg.