有没有人知道集中 .NET 应用程序配置以便计算机上的多个 Windows 服务和多个 wcf Web 服务可以使用它的方法?它们都安装在\program files 下的单独文件夹中。我们的软件目前为每个应用程序都有一个单独的应用程序配置,但试图维护它变得越来越疯狂。
虽然我们已经让每个应用程序引用一个可以从中央文件读取的 gac dll,但由于那些调用 wcf web 服务的应用程序的 wcf 客户端配置,这可能无法工作。
例如,我们通常在一台计算机上有 2 个或更多 wcf web 服务和/或 2 个或更多 windows 服务,它们每个都有自己的配置文件。
蒂亚
最佳答案
.NET配置文件可以reference another配置文件。如果您的应用程序部署方式与此类似:
Program Files \ MyCompany \ Shared.config
Program Files \ MyCompany \ ClientA \ ClientA.config
您可以从 ClientA.config
引用 Shared.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<appSettings file="..\Shared.config">
您也可以尝试将设置放入 machine.config .来自 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.
关于c# - Windows 服务和 WCF Web 服务的 .NET 集中配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7508462/