使用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,但如果我不得不求助于我.看起来有点像黑客.
有什么建议?