开发者

.NET - Child Processes and Configuration Files

I'm designing a windows service which is capable of starting up an arbitrary number of processes, each of which handle data processing on a different set of databases; sandboxes mirroring our live data processing service. The database connection information is stored in a config file, the location of which is specified in the app.config. Is it possible to change app.config data on a per-child-process basis?

I have my MasterService, which, for instance, starts up 2 new processes: DataProcessor1 and DataProcessor2. DataProcessor1 should be hitting database foo_1, and DataProcessor2 should be hitting database foo_2. However, by default the database configuration is set to data_service so that the MasterService can access what it needs to function independent of what its children are doing.

As I mentioned previously, the location of the database configuration is specified in the app.config. Is there a way for me to programmatically give each processes its own app.config, or change the app.config data on a per-process basis, so I can point each process at its own unique database开发者_C百科 configuration?

Our core libraries depend heavily on the data config setup we currently have, so changing it is rather out of the question. Likewise, injecting a custom db connection object is also not possible at this point in time.


Does the child process have to get it's connection string from the app.config? If not could you possibly just pass the connection string as a command line argument to the child process.

I believe you could use the ConfigurationManager class in System.Configuration to make runtime changes to the app.config, not sure if you can use it to change the path of the app.config to another file though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜