Application Settings Best Way Question

I

Icarus

I'm working on the design stage of a very flexible and parametrized
application. It'll hold about 50 to 60 diferent application settings.
Admin users sholud be able to change any application setting to set a new
application behavior.
I won't use app.config since application will be distributed using click
once and settings could change.
Settings type are diferent each other, I mean, It could have strings,
numeric or image settings.

I'll store settings on a Settings table inside a SQL Server Database.

I've been asking about the best way to do this and allways get this two
options:

1.- Map each setting to a column in the settings table, so I'll have as much
colums as application settings. Then create a class in which every property
holds an application setting. Each time I need to read an app setting I'll
read a class property. That class should contains a GetSettings methid to
refresh settings value.

2.- Define a IdSetting, SettingName, SettingValue table that contains each
application setting. A new query is completed every time I need to read a
setting value.

Can anyone point me to the right direction or share his experience doing
application settings without confi files?

T.I.A.

SG
 
M

Mr. Arnold

Icarus said:
I'm working on the design stage of a very flexible and parametrized
application. It'll hold about 50 to 60 diferent application settings.
Admin users sholud be able to change any application setting to set a new
application behavior.
I won't use app.config since application will be distributed using click
once and settings could change.

So you don't deploy the app.config in subsequent deployments.
Settings type are diferent each other, I mean, It could have strings,
numeric or image settings.

So, you have one application that's being used by multiple users?
I'll store settings on a Settings table inside a SQL Server Database.

I've been asking about the best way to do this and allways get this two
options:

1.- Map each setting to a column in the settings table, so I'll have as
much colums as application settings. Then create a class in which every
property holds an application setting. Each time I need to read an app
setting I'll read a class property. That class should contains a
GetSettings methid to refresh settings value.

2.- Define a IdSetting, SettingName, SettingValue table that contains each
application setting. A new query is completed every time I need to read a
setting value.

Can anyone point me to the right direction or share his experience doing
application settings without confi files?

Is this the only use for the SQL Server table is this app setting and
nothing else in the application is using SQL Server?

What version of the .Net framework is being used?
 
R

RobinS

I'm doing this using an XML file that is read into (and saved from) a
Dictionary<string, string>. You could as easily store it in SQLServer; that
would be overkill for us. We have about 50 settings that we are storing.

I created a class that I called ConfigManager that handles the updates,
deletes, etc. This is a static class that is in its own project, and is
called by the rest of the application, with methods like GetValue, Update
(which saves the dictionary to disk), Delete (which saves the dictionary),
etc.

Upon application startup, it checks to see if the file has been created, and
if not, it creates it. We have a bunch of hardcoded defaults, and then it
reads in whatever else is in the file, into the dictionary.

The XML file is being stored in a folder named by our company name, under
Environment.SpecialFolder.LocalApplicationData. It is different for every
user.

We deploy our application via ClickOnce. Since this file is not part of the
deployment, and not in the deployment folders, it is retained throughout the
updates. So if you want to update the file, you have to write code to do
that in the application. I haven't had to do that yet.

We don't use the application settings because of the issue with the updates,
and because we wanted finer control.

RobinS.
GoldMail, Inc.
 
I

Icarus

Thanks for the info RobinS. :)

RobinS said:
I'm doing this using an XML file that is read into (and saved from) a
Dictionary<string, string>. You could as easily store it in SQLServer;
that would be overkill for us. We have about 50 settings that we are
storing.

I created a class that I called ConfigManager that handles the updates,
deletes, etc. This is a static class that is in its own project, and is
called by the rest of the application, with methods like GetValue, Update
(which saves the dictionary to disk), Delete (which saves the dictionary),
etc.

Upon application startup, it checks to see if the file has been created,
and if not, it creates it. We have a bunch of hardcoded defaults, and then
it reads in whatever else is in the file, into the dictionary.

The XML file is being stored in a folder named by our company name, under
Environment.SpecialFolder.LocalApplicationData. It is different for every
user.

We deploy our application via ClickOnce. Since this file is not part of
the deployment, and not in the deployment folders, it is retained
throughout the updates. So if you want to update the file, you have to
write code to do that in the application. I haven't had to do that yet.

We don't use the application settings because of the issue with the
updates, and because we wanted finer control.

RobinS.
GoldMail, Inc.
 
I

Icarus

Mr. Arnold said:
So you don't deploy the app.config in subsequent deployments.


So, you have one application that's being used by multiple users? Yes


Is this the only use for the SQL Server table is this app setting and
nothing else in the application is using SQL Server?
The app uses SQL Server for data storage.
What version of the .Net framework is being used?
2.0
 
M

Mr. Arnold

Icarus said:
The app uses SQL Server for data storage.

2.0

There is a demo in the .Net 2.0 Application Block Demo, that you can
download, about using the app.config that holds configuration information
which is pulled into your application as an object. You you can access that
object's config data with ease in your application. The app.config demo
project also shows one how to use a SystemFileWatch to detect any changes in
the programname.app.config during run time to pull the new configuration
into the program and use them.

It may be something you'll want to look at, as I use it all the time with
Windows service and Console applications, where the programname.app.config
will have dynamic data in the config used at runtime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top