【发布时间】:2014-02-23 18:08:06
【问题描述】:
请帮我解决这个问题..
如何在 app.config 中不指定客户端配置的情况下创建 WCF 客户端。
我看过这个链接
.NET - deploying a WCF client, without an app.config
但是,您需要按属性指定配置属性。 无论如何,我们可以将 app.config 配置用作单个字符串并分配给一个类并完成它吗?
喜欢
var config=GetEndpointConfig(endPointName);
var bindingData=GetBinding(nameodBinding);
该方法在这样的字符串中返回整个配置。
端点:
<endpoint address="http://localhost:61144/Sampler.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Iervice" contract="IService"
name="BasicHttpBinding_IService" />
绑定:
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" 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" />
</security>
</binding>
</basicHttpBinding>
我不想导入配置文件并在当前应用程序中加载配置,因为还有其他模块会受到影响。我正在引用this 正在使用的示例
System.Configuration.Configuration config =
System.Configuration.ConfigurationManager.OpenMappedExeConfiguration
(filemap,
System.Configuration.ConfigurationUserLevel.None);
提前致谢!!!
【问题讨论】:
标签: c# wcf app-config