.net – 在app.config中管理多个客户端端点配置(IP地址等)的最佳方法

.net – 在app.config中管理多个客户端端点配置(IP地址等)的最佳方法,第1张

概述我们开发一个系统,其中客户端应用程序是使用Web服务与服务器通信的.NET客户端.我们需要能够使用不同的配置选项部署客户端,例如IP地址等 到目前为止,我们通过基本评论/取消评论app.config中的不同配置来管理这个,例如: <!--<client> <endpoint address="https://localhost/services/service1" bind @H_404_1@ 我们开发一个系统,其中客户端应用程序是使用Web服务与服务器通信的.NET客户端.我们需要能够使用不同的配置选项部署客户端,例如IP地址等
到目前为止,我们通过基本评论/取消评论app.config中的不同配置来管理这个,例如:

<!--<clIEnt>    <endpoint address="https://localhost/services/service1"        binding="customBinding" bindingConfiguration="ServiceSoapBinding"        contract="ServiceReference.Service1" name="ServiceImplPort" />    <endpoint address="https://localhost/services/service2"        binding="customBinding" bindingConfiguration="ServiceSoapBinding"        contract="ServiceReference.Service2" name="ServiceImplPort" />    ...    ..</clIEnt>--><clIEnt>    <endpoint address="https://prod.example.com/services/service1"        binding="customBinding" bindingConfiguration="ServiceSoapBinding"        contract="ServiceReference.Service1" name="ServiceImplPort" />    <endpoint address="https://prod.example.com/services/service2"        binding="customBinding" bindingConfiguration="ServiceSoapBinding"        contract="ServiceReference.Service2" name="ServiceImplPort" />    ...    ..</clIEnt>

但很明显,这不是问题的最佳解决方案,随着配置选择数量的增加,它变得有点难以管理.任何建议如何改善这一点是最受欢迎的.

问候,奥拉

解决方法 幸运的是,这个问题有一个很好的解决方案.下载并安装 MSBuild.Community.Tasks

然后查看以下帖子以获取示例用法

http://chris.widdowson.id.au/?p=781

http://grahamrhay.wordpress.com/2012/03/16/multiple-config-transforms-at-build-time/

警告设置时间超过5分钟,您将手动编辑.csproj文件

这个解决方案确实很有效,回过头来解决任何问题

总结

以上是内存溢出为你收集整理的.net – 在app.config中管理多个客户端端点配置(IP地址等)的最佳方法全部内容,希望文章能够帮你解决.net – 在app.config中管理多个客户端端点配置(IP地址等)的最佳方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1063146.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存