.NET Centralized Configuration for Windows Services and WCF Web Services
Does anybody know of a way to centralize a .NET app config so that it can be used by multiple windows services and multiple wcf web services on a computer? They are all installed in separate folders under \program files. Our software currently has a separate app config for each application but it's getting crazy trying to maintain it all.
We have though of having each application reference a gac dll that can read from a central file but that will probably not work due to the wcf client configuration for those apps that call wcf web services.
For example we will typically have 2 or more wcf开发者_高级运维 webservices and/or 2 or more windows services on a computer and they each have their own configuration files.
tia
.NET configuration file can reference another config file. If your apps are deployed similar to this:
Program Files \ MyCompany \ Shared.config
Program Files \ MyCompany \ ClientA \ ClientA.config
You can reference Shared.config
from ClientA.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<appSettings file="..\Shared.config">
You can also try putting settings into machine.config. From Configuring Services Using Configuration Files:
... This mechanism allows machine-wide settings to be defined in the Machine.config file. The App.config file can be used to override the settings of the Machine.config file; you can also lock in the settings in Machine.config file so that they get used.
精彩评论