473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Application Settings

I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationManager and AppSettings along with
a few other things I finally found that I could just use
global::Properties.xxx.Settings.Default.yyy

where xxx is the namespace and yyy is a setting created in the settings
dialog.

This is an extremly easy way to save and restore properties but I'm
wondering how general it is and if its a good idea to use it?

Also, where are these settings stored? It seems that its somewhere in the
CLR(maybe not the appropriate term) cache or something? The only way I
could reset the settings is by setting them to some default values and then
saving them.

One issue I was having was when I was using AppSettings[key]. I could never
find any settings even though I had both application and user defined
settings created in app.config. Are these settings suppose to be the same
as the ones above or are they different? (such as a different section/group
name in the xml config file?)

e.g., if I created a user or application defined setting called
"SomeSetting" in the settings page and then tried to reference it by
AppSettings["SomeSetting"], I would also get a null string.
Thanks,
Jon

Nov 15 '06 #1
3 3153
Hi Jon,

I can't give you as much help as others on here but I can tell you how
I use the settings.

In my solution explorer, there is a Properties folder beneath the
project. Expanding that out allows me to see the Resources and the
Settings. When I have something that I want to persist, I double click
on the Settings item and it brings up an editor to allow me to enter
the variables and their scope (application or user). Once I have my
variables set up, I go back to my code where I want to use them.

At the top, I put the following using statement:

using myNamespace.Properties;

That keeps me from having to type so much when I want to use them.
Then, in my code, I use

Settings.Default.MySetting

I do this for keeping track of the window size and position and some
colors. Mostly settings that the user will change. To get them to
persist between application uses, you must make the change to the
setting and then do a Settings.Default.Save. I usually do this in the
Closing event of my primary form.

I'm not exactly sure where they are saved. I've not had many problems
out of them and haven't investigated that. I did a quick search in the
documenation and didn't see anything obvious. I ran FileMon and watched
as a small app came up and then went down. It appears that there are
some files being opened and closed in my accounts Local Settings folder
as well as the Application Data folder.

HTH some

On Nov 15, 10:08 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com>
wrote:
I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationManager and AppSettings along with
a few other things I finally found that I could just use
global::Properties.xxx.Settings.Default.yyy

where xxx is the namespace and yyy is a setting created in the settings
dialog.

This is an extremly easy way to save and restore properties but I'm
wondering how general it is and if its a good idea to use it?

Also, where are these settings stored? It seems that its somewhere in the
CLR(maybe not the appropriate term) cache or something? The only way I
could reset the settings is by setting them to some default values and then
saving them.

One issue I was having was when I was using AppSettings[key]. I could never
find any settings even though I had both application and user defined
settings created in app.config. Are these settings suppose to be the same
as the ones above or are they different? (such as a different section/group
name in the xml config file?)

e.g., if I created a user or application defined setting called
"SomeSetting" in the settings page and then tried to reference it by
AppSettings["SomeSetting"], I would also get a null string.

Thanks,
Jon
Nov 15 '06 #2
The User Settings in .NET2 are saved in a folder in Application Data folder
for the user and the Application settings are saved in a settings file with
the app.
The AppSettings[string] is for reading the old <appSettingselement from
the config which is now completly defunct and marked obsolete I believe.

HTH

Ciaran O'Donnell

"gbgeek" wrote:
Hi Jon,

I can't give you as much help as others on here but I can tell you how
I use the settings.

In my solution explorer, there is a Properties folder beneath the
project. Expanding that out allows me to see the Resources and the
Settings. When I have something that I want to persist, I double click
on the Settings item and it brings up an editor to allow me to enter
the variables and their scope (application or user). Once I have my
variables set up, I go back to my code where I want to use them.

At the top, I put the following using statement:

using myNamespace.Properties;

That keeps me from having to type so much when I want to use them.
Then, in my code, I use

Settings.Default.MySetting

I do this for keeping track of the window size and position and some
colors. Mostly settings that the user will change. To get them to
persist between application uses, you must make the change to the
setting and then do a Settings.Default.Save. I usually do this in the
Closing event of my primary form.

I'm not exactly sure where they are saved. I've not had many problems
out of them and haven't investigated that. I did a quick search in the
documenation and didn't see anything obvious. I ran FileMon and watched
as a small app came up and then went down. It appears that there are
some files being opened and closed in my accounts Local Settings folder
as well as the Application Data folder.

HTH some

On Nov 15, 10:08 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com>
wrote:
I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationManager and AppSettings along with
a few other things I finally found that I could just use
global::Properties.xxx.Settings.Default.yyy

where xxx is the namespace and yyy is a setting created in the settings
dialog.

This is an extremly easy way to save and restore properties but I'm
wondering how general it is and if its a good idea to use it?

Also, where are these settings stored? It seems that its somewhere in the
CLR(maybe not the appropriate term) cache or something? The only way I
could reset the settings is by setting them to some default values and then
saving them.

One issue I was having was when I was using AppSettings[key]. I could never
find any settings even though I had both application and user defined
settings created in app.config. Are these settings suppose to be the same
as the ones above or are they different? (such as a different section/group
name in the xml config file?)

e.g., if I created a user or application defined setting called
"SomeSetting" in the settings page and then tried to reference it by
AppSettings["SomeSetting"], I would also get a null string.

Thanks,
Jon

Nov 15 '06 #3

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:24******************@newssvr21.news.prodigy.c om...
>I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationManager and AppSettings along
with a few other things I finally found that I could just use
global::Properties.xxx.Settings.Default.yyy

where xxx is the namespace and yyy is a setting created in the settings
dialog.

This is an extremly easy way to save and restore properties but I'm
wondering how general it is and if its a good idea to use it?

Also, where are these settings stored? It seems that its somewhere in the
CLR(maybe not the appropriate term) cache or something? The only way I
could reset the settings is by setting them to some default values and
then saving them.

One issue I was having was when I was using AppSettings[key]. I could
never find any settings even though I had both application and user
defined settings created in app.config. Are these settings suppose to be
the same as the ones above or are they different? (such as a different
section/group name in the xml config file?)

e.g., if I created a user or application defined setting called
"SomeSetting" in the settings page and then tried to reference it by
AppSettings["SomeSetting"], I would also get a null string.

Ok, thanks guys. One more thing though. It seems one can be more general(or
maybe I mean specific) in defining settings and create sections and groups
using some methods in configurationmanager? I'm just curious about this as
I might need it later. What I have found off the net doesn't give much
explination of how it works and the msdn is pretty bad at explaining the
details.

As far as I can tell is that the configuration data is stored in XML files
and one can create "nodes" and data using some methods that abstract the XML
details. Is this about right?

Thanks again,
Jon
Nov 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Google Mike | last post by:
I need an Application object replacement. I was creating my own using shared memory -- shm* API in PHP. I was doing fine for 6 months until it just got too fat, I guess, and the RH9 Linux server...
1
by: serge calderara | last post by:
dear all, I have problem accessing section group in my configuration application file. I got an error saying thta I can have only one section ???? here is my application configuration looks...
4
by: Lars Netzel | last post by:
I just saw this program called Handy Backup 4.5 where you can add backup jobs as such... and I wonder where you normally save data in an application. I come from an ASP world and have started to...
1
by: Cristian | last post by:
Hi I have some trouble (on only one developer computer) with the application settings functions... I have posted to the Microsoft.Public.vstudio.setup group but they couldn't help me and asked...
2
by: Bob | last post by:
The my.settings name space is easy to use to modify User settings from within code, but the application settings can't seem to be modified that easily. I want the user to be able to modify some of...
3
by: xycos | last post by:
Hello. I apologize for asking this question as the information I need is availible via the MSDN library, however I cannot seemt o understand what I need to do, so I'm asking here. I have created...
0
by: steve | last post by:
I am using vb.net 2005 Express Edition. Application Settings would be a very useful thing, as a global program database that persists; if only it would work! Does anyone know a hack or a...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I've done this type of thing many times before so I know it works, but for some reason it's not working in this particular application. In an event handler I save some values into the...
1
by: BobLewiston | last post by:
I tried to compile a Windows Forms Application in Visual C# 2008 Express with this source code from the CSharpSchool tutorial at Programmer's Heaven:using System; using System.Windows.Forms; using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.