如何使用控制台输入更改app.config中的端点地址? [英] How can I change the endpoint address in app.config with the console input?
本文介绍了如何使用控制台输入更改app.config中的端点地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个有服务参考的应用。我需要根据用户的控制台输入更改app.config文件中端点地址的URL。我如何通过C#做到这一点?请给我建议。
I have an app which has a service reference. I need to change the URL of the endpoint address in app.config file based on the console input from user. How do I do this through C#? Please advice.
<pre lang="xml"><configuration>
<system.servicemodel>
<bindings>
<basichttpbinding>
<binding name="BasicHttpBinding_IBrokerService" closetimeout="00:01:00">
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientcredentialtype="None" proxycredentialtype="None">
realm="" />
<message clientcredentialtype="UserName" algorithmsuite="Default" />
</transport></security>
</readerquotas></binding>
</basichttpbinding>
</bindings>
<client>
<endpoint address="http://abcd/defgf/test.svc" binding="basicHttpBinding">
bindingConfiguration="BasicHttpBinding_ITestService" contract="TestServiceProxy.ITestService"
name="BasicHttpBinding_ITestService" />
</endpoint></client>
</system.servicemodel>
</configuration> </pre>
我需要更改端点地址中的abcd用户通过控制台指定的值。
I need to change the "abcd" in endpoint address with the user specified value through console.
推荐答案
您好朋友,您可以访问以下链接:
< a href =http://blogs.msdn.com/b/youssefm/archive/2010/01/21/how-to-change-net-configuration-files-at-runtime-including-for-wcf.aspx >如何在运行时更改.NET配置文件(包括WCF) [ ^ ]
Hello friend, you may visit the below link:
How to Change .NET Configuration Files at Runtime (including for WCF)[^]
这篇关于如何使用控制台输入更改app.config中的端点地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文