简体   繁体   中英

How to share the same settings (or configuration) between apps and windows services (even if they run in different PCs)

I'm developing a big solution with C#. Some projects are .NET Framework 4.0 (most of them) and others are .NET Framework 4.6.2.

This solution has WinForm applications and Windows Services.

My problem is that all of these applications share database connections strings, servers' IP, etc. and I have to modify each of its config file to update all these configuration settings.

I want also to have encrypted these settings to don't allow users to modify them.

I thought to use Windows' Registry, or an encrypted SQL lite database, or event another windows services with a Web API interface to ask for each of these settings.

What do you recommend me?

By the way, all of this programs will be installed in different PC so I have to use that solution to all of these PCs or maybe I can have all the settings in one PC only.

What do you suggest me?

If you need to synchronise such information between different computers then you need some kind of centralised service to do this.

One idea is Apache Zookeeper .

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications

The concern I would have is that maybe Zookeeper might be too much for your project as it is designed for distributed applications and is could be overkill, although you can deploy it on a single node.

I hardly recommend a Web API interface. If you use a Web API you can change how to store the settings and you only have to change the Web API backend. The methods for getting the settings can be still the same and you don't have to change anything in your consuming apps or services.

If you would connect directly to a database you have to store at least the connection string to this database in each application and if it's changing you have to update all consumers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM