【发布时间】:2010-09-06 09:11:52
【问题描述】:
使用 C# .NET 3.5 和 WCF,我试图在客户端应用程序中写出一些 WCF 配置(客户端连接到的服务器的名称)。
显而易见的方法是使用ConfigurationManager 来加载配置部分并写出我需要的数据。
var serviceModelSection = ConfigurationManager.GetSection("system.serviceModel");
似乎总是返回 null。
var serviceModelSection = ConfigurationManager.GetSection("appSettings");
完美运行。
配置部分存在于 App.config 中,但由于某种原因 ConfigurationManager 拒绝加载 system.ServiceModel 部分。
我想避免手动加载 xxx.exe.config 文件并使用 XPath,但如果我不得不求助于它,我会的。只是看起来有点像 hack。
有什么建议吗?
【问题讨论】:
标签: c# .net xml wcf configurationmanager