【发布时间】:2013-07-24 14:44:51
【问题描述】:
我有一个小型 WCF 客户端,我正在尝试通过应用程序配置文件配置服务发现 - 但是每当我这样做时:
// Create a new DiscoveryClient instance from the 'DiscoveryEndpoint'
// configuration in App.config
DiscoveryClient discoveryClient = new DiscoveryClient("DiscoveryEndpoint");
我收到了ArgumentNullException、Value cannot be null. Parameter name: contract。 DiscoveryClient构造函数的这个重载没有contract参数,并且在App.config中正确指定了契约(见下文)。
以下是 App.config 的相关部分:
<system.serviceModel>
<client>
<endpoint name="DiscoveryEndpoint"
contract="IExampleContract"
kind="dynamicEndpoint"
endpointConfiguration="DynamicEndpointConfiguration"/>
</client>
<standardEndpoints>
<dynamicEndpoint>
<standardEndpoint name="DynamicEndpointConfiguration">
<discoveryClientSettings>
<endpoint kind="udpDiscoveryEndpoint"/>
<findCriteria duration="00:00:02">
<types>
<add name="IExampleContract"/>
</types>
<scopes>
<add scope="urn://wcf.test.com/examples/exampleContract/development"/>
</scopes>
</findCriteria>
</discoveryClientSettings>
</standardEndpoint>
</dynamicEndpoint>
</standardEndpoints>
</system.serviceModel>
这是针对 .NET Framework 4.0,使用 Visual Studio 2010 SP1。
DiscoveryClient(string) 构造函数重载的文档表明,这应该使用 App.config 中标识的配置创建一个新的 DiscoveryClient 实例。
有没有其他人遇到过这种行为,如果有,您是如何解决的?
【问题讨论】: