473,397 Members | 2,068 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,397 software developers and data experts.

Dynamic settings entries with Application Settings.

I've read the "How to: Create Application Settings" article (http://
msdn2.microsoft.com/en-us/library/ms171565.aspx) on the MSDN. It
looked fine. But this code is only good when all the settings entries
are defined at the compile time. And I have to modify the class itself
each and everytime I need more entries. So, is it impossible to get/
save dynamic entries?

I mean, instead of,
MyUserSettings.Background=color;
color=MyUserSettings.Background;

use this
MySettings["key"]=color;
color=MySettings["key"];
where "key" can be any string. If "key" doesn't exist, then a new
entry for "key" is created.

I could create my own class from scratch, but I just wonder if I could
utilize the already exsiting ApplicatoinSettingsBase class. Thank you.

Feb 1 '07 #1
2 4132
You could certainly do this since the configuration file is well-formed XML.
The problem is that when you have modified and resaved this file, your
application will not automatically reload it unless it is restarted. If it is
an ASP.NET web app, and you modify the web.config (same concept) this will
cause the application to restart, and you will lose all session, cache and
application state.

Does that help?
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Sin Jeong-hun" wrote:
I've read the "How to: Create Application Settings" article (http://
msdn2.microsoft.com/en-us/library/ms171565.aspx) on the MSDN. It
looked fine. But this code is only good when all the settings entries
are defined at the compile time. And I have to modify the class itself
each and everytime I need more entries. So, is it impossible to get/
save dynamic entries?

I mean, instead of,
MyUserSettings.Background=color;
color=MyUserSettings.Background;

use this
MySettings["key"]=color;
color=MySettings["key"];
where "key" can be any string. If "key" doesn't exist, then a new
entry for "key" is created.

I could create my own class from scratch, but I just wonder if I could
utilize the already exsiting ApplicatoinSettingsBase class. Thank you.

Feb 1 '07 #2
First of all, thank you for your reply.
You could certainly do this since the configuration file is well-formed XML.
But, what do you mean by this? Does this mean that 1)I can do create
my own settings class from scratch or 2)I can derive a class that does
that from the ApplicationSettingsBase?

I tried
this["undefined key"]=value;
but it causes an exception. How can I dynamically add the "undefined
key" at run-time?

On Feb 1, 10:12 am, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
You could certainly do this since the configuration file is well-formed XML.
The problem is that when you have modified and resaved this file, your
application will not automatically reload it unless it is restarted. If it is
an ASP.NET web app, and you modify the web.config (same concept) this will
cause the application to restart, and you will lose all session, cache and
application state.

Does that help?
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"Sin Jeong-hun" wrote:
I've read the "How to: Create Application Settings" article (http://
msdn2.microsoft.com/en-us/library/ms171565.aspx) on the MSDN. It
looked fine. But this code is only good when all the settings entries
are defined at the compile time. And I have to modify the class itself
each and everytime I need more entries. So, is it impossible to get/
save dynamic entries?
I mean, instead of,
MyUserSettings.Background=color;
color=MyUserSettings.Background;
use this
MySettings["key"]=color;
color=MySettings["key"];
where "key" can be any string. If "key" doesn't exist, then a new
entry for "key" is created.
I could create my own class from scratch, but I just wonder if I could
utilize the already exsiting ApplicatoinSettingsBase class. Thank you.

Feb 1 '07 #3

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

Similar topics

1
by: mhouglum | last post by:
I was wondering, is it possible to programmatically change the initial settings of an EventLog? Specifically, I would like to create an EventLog that was set to overwrite events as needed rather...
3
by: Damian | last post by:
Hi everyone I'm having an issue with one of our applications. I'm getting the following error when attempting to log in to the site: Server Error in 'xxxxxxxxxxxxxxxx' Application....
3
by: Jason Kendall | last post by:
I've recently installed Beta 2 ov Visual Studio and an updating a few small applications as a way to get my feet wet with some of the new functionality. There are many new features which are...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
3
by: penguin732901 | last post by:
What do experienced programmers find the most efficient way to handle user settings. Currently I have 4 tables which allow various clients to customize my program to work for them,...
7
by: lord.zoltar | last post by:
I have a problem which I think can be solved by creating new Settings on the fly, but I'mnot sure if it's possible, or if a better solution may exists. Here's the situation: I have a project with...
2
by: =?Utf-8?B?QWFyb24=?= | last post by:
I am trying to create dynamic settings in a .NET 2.0 C# application. I need to be able to store settings on the user, but I do not know how many settings are necessary at design time because the...
7
by: Just_a_fan | last post by:
I save some data to an array in my program. I can reopen the setting screen and see that the data is, in fact, in the array. I then do a lot of these: My.Settings.Brkr1 = BreakerAmps(1)...
6
by: AGP | last post by:
VB.NET 2005 I've been working extensively with saving and loading my settings via the My.Settings class. its worked out great except that i cant figure out how to set a default setting that is...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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
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...
0
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...

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.