相关疑难解决方法(0)

使用ConfigurationManager加载System.ServiceModel配置节

使用C#.NET 3.5和WCF,我试图在客户端应用程序中写出一些WCF配置(客户端连接到的服务器的名称).

显而易见的方法是使用ConfigurationManager加载配置部分并写出我需要的数据.

var serviceModelSection = ConfigurationManager.GetSection("system.serviceModel");
Run Code Online (Sandbox Code Playgroud)

似乎总是返回null.

var serviceModelSection = ConfigurationManager.GetSection("appSettings");
Run Code Online (Sandbox Code Playgroud)

完美的工作.

配置部分存在于App.config中,但由于某种原因ConfigurationManager拒绝加载该system.ServiceModel部分.

我想避免手动加载xxx.exe.config文件并使用XPath,但如果我不得不求助于我.看起来有点像黑客.

有什么建议?

.net c# xml wcf configurationmanager

60
推荐指数
5
解决办法
6万
查看次数

标签 统计

.net ×1

c# ×1

configurationmanager ×1

wcf ×1

xml ×1