all groups > dotnet general > february 2008 >
You're in the

dotnet general

group:

Application Settings Best Way Question



Application Settings Best Way Question Icarus
2/12/2008 10:36:43 AM
dotnet general: 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

Re: Application Settings Best Way Question Mr. Arnold
2/12/2008 10:06:30 PM

[quoted text, click to view]

So you don't deploy the app.config in subsequent deployments.

[quoted text, click to view]

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

[quoted text, click to view]

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?
Re: Application Settings Best Way Question RobinS
2/12/2008 11:51:15 PM
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.
----------------------------
[quoted text, click to view]
Re: Application Settings Best Way Question Icarus
2/13/2008 10:44:23 AM
Thanks for the info RobinS. :)

"RobinS" <robins@imnottelling.com> escribió en el mensaje
news:-72dnZOE5rzuPC_anZ2dnUVZ_sytnZ2d@comcast.com...
[quoted text, click to view]

Re: Application Settings Best Way Question Icarus
2/13/2008 10:45:42 AM

"Mr. Arnold" <MR. Arnold@Arnold.com> escribió en el mensaje
news:uLamy1ebIHA.5892@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]
Yes

[quoted text, click to view]
The app uses SQL Server for data storage.

[quoted text, click to view]
2.0

Re: Application Settings Best Way Question Mr. Arnold
2/13/2008 8:06:34 PM

[quoted text, click to view]

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.


AddThis Social Bookmark Button