c# - Windows 服务和 WCF Web 服务的 .NET 集中配置

标签 c# wcf configurationmanager

有没有人知道集中 .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/

相关文章:

c# - 将 TreeView 的内容保存到文件并稍后加载

c# - 如何获取以空格分隔的输入

c# - String.Contains 和 String.LastIndexOf C# 返回不同的结果?

c# - WCF maxReceivedMessageSize 不能设置超过 4215

c# - ConfigurationManager.AppSettings 的作用是什么?

c# - Elasticsearch 嵌套 : Fetching random documents

WCF IErrorHandler 将 FaultException 返回给 SOAP,将 WebHttpException 返回给 POX 和 Json 端点

c# - 如何将日期时间参数提交给 WCF REST 服务

c# - 如何获取 ConfigurationSection 属性作为 System.Type

asp.net - 如何通过ConfigurationManager找到配置文件位置?