gpt4 book ai didi

c# - 如何从 app.config 获取此配置值?

转载 作者:太空狗 更新时间:2023-10-29 22:24:46 27 4
gpt4 key购买 nike

我的 friend 有以下 app.config。他想获取address 的值。怎么做?

<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>

最佳答案

试试这个来获取第一个端点

Configuration configuration =    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();

关于c# - 如何从 app.config 获取此配置值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com