Hi,
I use the user settings nice and easy. Works perfect for all types objects.
As far as I understand, when the Application Scope is User, settings saved separately for each user, by computer and user name.
The problem is when I try to save the settings as Application scope, namely to be available to all users, regardless of user or computer.
While the Setting Interface accepts the setting with Application scope,when assigning a value to the setting, the program returns read-only error at design time.
I have looked into tens of web sites and information, all telling me to save as User, but I need it as common application setting, not per user.
Example: I define a 'versiondate' setting as type DateTime, Scope: Application, no value at this time.
I then set:
Properties.Settings.Default.versiondate = DateTime.Now; (Or any other legal DateTime object)
which will give me:
Error1Property or indexer 'Properties.Settings.fareDataSetApp' cannot be assigned to -- it is read only.....
To make a long story short: How can I preserve the Application settings (NOT User scope) using the standard setting form?
And, one more thing: Going through all documentation I found, I did not find any explanation on how to use the Value field in the setting form. (I expected to find there a list of all project's objects, by class or method, but I do not!)
Thanks.
Loading
SamPosted Jun 28, 2013, 12:59 PM
VulpesPosted Jun 18, 2013, 2:25 PM
Properties.Settings.Default.versiondate = DateTime.Now;
you're assigning (or attempting to assign) the setting 'versiondate' a value at run time, not design time.
if you wanted to set it as design time, you'd need to open up the Settings tab of the project's Properties and, having set the type to System.DateTime, select a value from the drop-down calendar.
SamPosted Jun 18, 2013, 1:15 PM
VulpesPosted Jun 18, 2013, 11:59 AM
Incidentally, I wasn't suggesting that you shouldn't use Settings at all - they're fine except in this particular scenario.
Although this is an old article (goes back to VS 2005 days), I can remember reading it at the time and it should tell you all you need to know about Settings:
http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx
SamPosted Jun 18, 2013, 10:42 AM
Sure, I could write some code lines to serialize the information and save as xml, and then another code to read and parse it, but why not use VS tools (that eventually do the same, namely serialization and xml file).
The advantage with using the built-in Setting is that it can save even complex Objects (I save a 9-table dataset as one object, as well as DateTime objects), not just data, and it is supposed to be simple to use, as I experience with the User settings.
The VS Setting panel seem to be set to do just that - but I assume I am doing something wrong.
Or otherwise, why doe it have User or Application Scope selection?
Have you tried it? Did anyone?
Thanks
VulpesPosted Jun 18, 2013, 8:33 AM
You can do whatever you like then.