多个 WCF 服务调用上的 TargetInitationException

发布于 2024-09-03 01:03:37 字数 2078 浏览 7 评论 0原文

我正在使用 SL 4 和 .net-4 WCF 服务以及 PollingDuplexHttpBinding。调用服务并从服务回调客户端效果很好。但是,一旦我调用该服务(例如 15 次)而无需等待异步答案,我就会在获得 0、1 或 2 个成功答案后收到 TargetInitationException。

我的服务属性是:

[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 新手:我错过了什么吗?

I'm using SL 4 and a .net-4 WCF service with a PollingDuplexHttpBinding. Calling the service and calling the client back from the service works fine. But as soon as I call the service, say 15 times without waiting for the async answer, I receive a TargetInvocationException after getting 0, 1 or 2 successful answers.

My attributes for the service are:

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

This is in my 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>

And like this, I instantiate the service on client side:

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

As I'm new to WCF: did I miss something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缘字诀 2024-09-10 01:03:37

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

TargetInvocationException should have a InnerException property containing the actual exception, it might give you some clues.

二智少女 2024-09-10 01:03:37

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

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

No it doesn't give any clue. The remote server return an error Not Found.

The call to async is done, but it never go to the server and it gets immediately the error in the callback

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文