1

我正在使用 SL 4 和带有 PollingDuplexHttpBinding 的 .net-4 WCF 服务。调用服务并从服务中调用客户端工作正常。但是,一旦我调用该服务,比如说 15 次而不等待异步答案,我会在获得 0、1 或 2 个成功答案后收到 TargetInvocationException。

我的服务属性是:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
    ConcurrencyMode = ConcurrencyMode.Multiple)]

这是在我的 web.config 中:

<behaviors>
  <serviceBehaviors>
    <behavior name="RecordProviderServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceTimeouts transactionTimeout="05:05:00" />
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500"
       maxConcurrentInstances="2147483647" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
  <pollingDuplexHttpBinding>
    <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
       maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
       maxOutputDelay="00:00:00.200" duplexMode="MultipleMessagesPerPoll" />
  </pollingDuplexHttpBinding>
</bindings>

像这样,我在客户端实例化服务:

var binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll)
                          {
                              MaxBufferSize = 2147483647,
                              MaxReceivedMessageSize = 2147483647
                          };
        _service = new ServiceClient(new InstanceContext(this),
                                            binding,
                                            new EndpointAddress("path to .svc"));

因为我是 WCF 的新手:我错过了什么吗?

4

2 回答 2

2

TargetInvocationException 应该有一个包含实际异常的 InnerException 属性,它可能会给你一些线索。

于 2010-05-26T14:53:57.303 回答
0

不,它没有给出任何线索。远程服务器返回错误未找到。

对 async 的调用已完成,但它永远不会转到服务器,它会立即在回调中收到错误

于 2012-06-07T12:11:31.057 回答