在app.config控制台应用程序中配置轮询双工

时间:2012-04-24 14:27:30

标签: wcf app-config console-application pollingduplexhttpbinding

我在控制台应用程序中配置轮询双工绑定时遇到问题。这是我收到的错误:

Configuration binding extension 'system.serviceModel/bindings/pollingDuplexHttpBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

此外,这是我app.config中的一个片段:

    <extensions>
      <bindingExtensions>
        <add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,
         System.ServiceModel.PollingDuplex,
         Version=4.0.0.0,
         Culture=neutral,
         PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
    </extensions>

    <services>
      <service behaviorConfiguration="PositionBehaviour" name="RabbitMQSub.PositionUpdates">
        <endpoint address="positionsDUPLEX" binding="pollingDuplexHttpBinding" contract="RabbitMQSub.IPositionUpdates">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/RabbitMQSub/PositionsDUPLEX" />
          </baseAddresses>
        </host>

      </service>
    </services>

<behaviors>
  <serviceBehaviors>
    <behavior name="PositionBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <serviceTimeouts transactionTimeout="10:00:00"/>
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

问题

  • 是否可以在控制台应用中配置轮询双工?
  • 如果是的话,我做错了什么?

由于

1 个答案:

答案 0 :(得分:0)

据我所知,PollingDuplexHttpBinding不能用作.NET Framework的客户端组件。

实际上,您知道,拥有发布通知的客户端不需要双工功能 - 它可以构建为通过简单绑定(如BasicHttpBinding)公开的单独请求/响应WCF服务端。对于真正需要通过双工合同接收异步通知的Windows应用程序或控制台客户端,请考虑使用WsDualHttpBinding或NetTcpBinding,它们都提供双工通信。

虽然在最新版本的.NET Framework中可能已经发生了变化(可能没有) - 尝试添加对System.ServiceModel.PollingDuplex.dll的引用(如果可用)。