开发者

Where to store application settings

I am creating an app that reads some info from a scale via RS232 serial port connection. There are a couple of types of scales that are in use, so I would like to store specific settings for the scale in my program. What is the best way to do this? Via app.config? Or should I put the valu开发者_如何转开发es in a database?


It really depends on where will these configurations be used?

If you are working on a distributed huge system, which means these configurations are probably shared/used by other systems. You'd better store it in the database, with a common protocol which other related systems agree with.

On the other hand, if these configurations are used for a small application, storing them in a config file(or an xml file whatever you like) is suggested because, you don't need a gun in order to kill a mosquito.


app.config would be the easiest option for you. I think a database might be a bit overdoing it for just some settings, but if you wish to use something outside of what is offered by VS (namely app.config) then you could always whip up a quick custom XML settings file. All depends on what you wanna do with it and how comfortable you are with the other technology.


Is the information chaging ? that means when you ran ur app , would it be the case that information is updated ?

if the information is static and do not change frequetly , you can store in the app.config.

or in a xml file and you can read that information lately.

but if the information is dynamic then you need to create a model and expose scale information through model's peroperty.


Do not forget the registry.

Use the registry when:

  • You need your settings to be accessible for a domain admin
  • you need to secure some settings (using Windows security)
    (You can make some settings read-only)
  • There are a lot of small settings that change very often


If it's simple and straightforward than app.config is the way to go - you don't need to set up a database and you get to use simple built-in interfaces.

If you choose to go with a database check out mysql for a simple file based database that has a simple deployment scheme.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜