如何使用控制台输入更改app.config中的端点地址? [英] How can I change the endpoint address in app.config with the console input?

查看:74
本文介绍了如何使用控制台输入更改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">&lt;configuration&gt;
    &lt;system.servicemodel&gt;
        &lt;bindings&gt;
            &lt;basichttpbinding&gt;
                &lt;binding name="BasicHttpBinding_IBrokerService" closetimeout="00:01:00"&gt;
                    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"&gt;
                    &lt;readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384"&gt;
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                    &lt;security mode="None"&gt;
                        &lt;transport clientcredentialtype="None" proxycredentialtype="None"&gt;
                            realm="" /&gt;
                        &lt;message clientcredentialtype="UserName" algorithmsuite="Default" /&gt;
                    &lt;/transport&gt;&lt;/security&gt;
                &lt;/readerquotas&gt;&lt;/binding&gt;
            &lt;/basichttpbinding&gt;
        &lt;/bindings&gt;
        &lt;client&gt;
            &lt;endpoint address="http://abcd/defgf/test.svc" binding="basicHttpBinding"&gt;
                bindingConfiguration="BasicHttpBinding_ITestService" contract="TestServiceProxy.ITestService"
                name="BasicHttpBinding_ITestService" /&gt;
        &lt;/endpoint&gt;&lt;/client&gt;
    &lt;/system.servicemodel&gt;
&lt;/configuration&gt; </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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆