开发者

Where to store different configuration settings? C# service

This is my first time working with config files, so I am not sure which direction to开发者_Go百科 go. I have looked around but have not found any specific answers.

I have a some configuration settings, namely a list of integers, a list of custom objects and a single integer. At the moment, I am pursuing XML for my config file, I am using serialisation to store and read my list of custom objects. However, I am not sure of the convention or the possiblitly of storing the other settings in the same file. Ideally I would like it to be a single file configurable via a GUI, can I acheive this with XML?

How can I store and read my other list, and single int independently? i.e. refer to that part of the file? - does serialisation allow for this or do I need multiple files? Would that be bad practice?

Should I use a differnt type of config file, or use settings in addition to my XML file? Is it bad practice to have more than one mode of configuration?

Many thanks for any advice you can provide!


I used to store configuration information in app.config file (not separate). However working for big companies I found that on production you don't have access to app.config file (only IT personal can have access to production). So if you need to change configuration you need to go through change request, and it takes time. So in this case I started to store my configuration information in database. This way I can change at any time and I don't need go through change request.

About separate xml or app.config. I would use separate config file in case if you have a lot of config information, or information that is structured/nested, but most of the time (99%) I would use just app.config for this.

Check this out how to store int array in application settings


If its a windows service you probably want to use the registry

If its a WCF service then there is a well defined XML format for them that uses the .net .config format.

You can add custom settings in here and also custom sections with their own format rules.


Check this out How to store int[] array in application Settings


What version of .NET / VS.NET do you have ? VS 2008 and later, you can add a custom configuraction file, that is a XML internally, but can be modified by a custom grid editor in the IDE

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜