473,851 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application Settings

I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationMa nager and AppSettings along with
a few other things I finally found that I could just use
global::Propert ies.xxx.Setting s.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
"SomeSettin g" in the settings page and then tried to reference it by
AppSettings["SomeSettin g"], I would also get a null string.
Thanks,
Jon

Nov 15 '06 #1
3 3186
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.Pro perties;

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

Settings.Defaul t.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.Defaul t.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 ConfigurationMa nager and AppSettings along with
a few other things I finally found that I could just use
global::Propert ies.xxx.Setting s.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
"SomeSettin g" in the settings page and then tried to reference it by
AppSettings["SomeSettin g"], 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 <appSettingsele ment 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.Pro perties;

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

Settings.Defaul t.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.Defaul t.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 ConfigurationMa nager and AppSettings along with
a few other things I finally found that I could just use
global::Propert ies.xxx.Setting s.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
"SomeSettin g" in the settings page and then tried to reference it by
AppSettings["SomeSettin g"], I would also get a null string.

Thanks,
Jon

Nov 15 '06 #3

"Jon Slaughter" <Jo***********@ Hotmail.comwrot e in message
news:24******** **********@news svr21.news.prod igy.com...
>I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationMa nager and AppSettings along
with a few other things I finally found that I could just use
global::Proper ties.xxx.Settin gs.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
"SomeSettin g" in the settings page and then tried to reference it by
AppSettings["SomeSettin g"], 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 configurationma nager? 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
2722
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 just started "losing its memory". I don't know -- perhaps I'm doing something wrong, perhaps it's my code, or perhaps there's a limitation on what I'm trying to do here. It's too many lines of code to debug right now. I'm searching for...
1
2772
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 like: ================================================ <?xml version="1.0" encoding="utf-8" ?>
4
1561
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 get into Windows Forms and Desktop programming and for me it's always been a Database-Way to go when wanting to save data.. or in the Registry when it comes to usersettings. But in the application I was looking at I looked into the installation...
1
1897
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 me to post in this forum. I paste both the messages I posted there.. --- Hi I have just installed VS2005 and the first thing I did was to try out the new Screensaver sample. that wouldn't work it just crashed all the time.
2
13138
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 the application setting ( like my connection strings) through a friendly user interface on one of my forms, without having to go in the .config file with notepad. If its in my code I can do testing and validating when he chages things. Any...
3
4798
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 application settings in Visual Studio (right-click on the project, go to the settings tab, etc.) and have associated each of these settings with a property on a form. This seems to be working right (i.e. if I edit the default value of a setting,...
0
4002
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 work-around to get it working? For me, it seems to mess up the path of the folder where user.config is saved. If I Access the property :--
1
1819
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 application settings, such as: Settings.Default.host = some value; Settings.Default.port = some value; Settings.Default.userName = some value;
1
4525
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 System.Drawing; namespace CSharpSchool { class HelloWinForm { static void Main () { Application.Run (new MyWindow ());
0
9895
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9744
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10725
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9503
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7900
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5931
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.