[英]how to get this config value from app.config?
My friend has the following app.config. 我的朋友有以下app.config。 He wants to get the value of
address
. 他想得到
address
的价值。 how to do it? 怎么做?
<configuration>
<system.serviceModel>
...
<client>
<endpoint address="http://ldo:8080/LLService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ILLService" contract="LLServiceReference.ILLService"
name="WSHttpBinding_ILLService">
<identity>
<userPrincipalName value="ggldoe@mail.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
...
</configuration>
try this to Get first endpoint 试试这个以获得第一个端点
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();
Take a look at the <system.serviceModel>
documentation in MSDN . 查看MSDN中的
<system.serviceModel>
文档 。
You should: 你应该:
ServiceModelSectionGroup.GetSectionGroup
method ServiceModelSectionGroup.GetSectionGroup
方法 serviceModelSectionGroup.Client.Endpoints
collection. serviceModelSectionGroup.Client.Endpoints
集合中选择一个端点。 Presumably you want to look at a specific contract. Address
property Address
属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.