0

I have multiple projects in a solution. Each project has its own app.config file. I want to have a single app.config or settings file which can be used across the solution. What I see is now, when i want to add some settings common to the application I will have to add an entry it in all the projects app.config file.

I want to have a single configurable file (XML) which can be used in whole application. At run time if the value of any key is changed, my application should be able to get that changed value from the XML.

Tasos K.
  • 7,979
  • 7
  • 39
  • 63
Rem San
  • 367
  • 1
  • 5
  • 20
  • 1
    At the end you have only one running application? please also mention types for projects under the solution – ElasticCode Mar 21 '19 at 02:34
  • at the end i have one application and a web server portal. 3 folders in a solution: Client (exe), Common(utilities can be used by both client and server) and Server(web portal). In common folder i have a logger class which is used for logging. log file size should be customizable, for this purpose xml file is used. – Rem San Mar 21 '19 at 02:50
  • by default logger or any class lib will read its configuration from main app configuration – ElasticCode Mar 21 '19 at 03:19

2 Answers2

0

It's a arquiteture problem. Why you can't have a unique webconfig file. Everytime that you need to update an application, will have to update all. I think It's wrong.

You can to try a solution bellow:

  1. The best and correct option. Uses one commom Redis Cache. Everybody can call it.

  2. Save the configuration in one commom database table. So will have only one update in the solutions changes.

  3. Use a noSql(mongodb, cosmosdb etc.) database. It's faster then sql.

  4. Use one WebAPI. You can consult the configurations and to caching the information in each service.

obs: But if you whant a file. Can put in the solution and create a command to copy and replace the config when to build the solution. Like this:

Copying Visual Studio project file(s) to output directory during build

flw

Davidson Dd-harlie
  • 151
  • 1
  • 2
  • 9
0

You can use a linked file for using the same file in multiple projects in the same solution. This is good for using in multiple test projects that run either locally or from a build machine, however, for production code a centralized configuration would be a better approach.

For linking a file via the "Add Existing Item" select the arrow on the "Add" button and then choose "Add As Link".

Danny Varod
  • 17,324
  • 5
  • 69
  • 111