首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我需要在web.config中修复什么才能使这个MSDN示例正常工作?

我需要在web.config中修复什么才能使这个MSDN示例正常工作?
EN

Stack Overflow用户
提问于 2011-03-23 20:25:25
回答 2查看 3.2K关注 0票数 2

在Visual 2010中使用.NET 4和Silverlight 4,我试图按照MSDN指南为Silverlight客户端(http://msdn.microsoft.com/en-us/library/cc645027(v=vs.96).aspx )构建一个双工服务。

Web.config发出警告:

警告26元素“绑定”具有无效的子元素“pollingDuplexHttpBinding”。可能需要的元素列表:'basicHttpBinding,customBinding,msmqIntegrationBinding,netPeerTcpBinding,netMsmqBinding,netNamedPipeBinding,netTcpBinding,wsFederationHttpBinding,ws2007FederationHttpBinding,wsHttpBinding,ws2007HttpBinding,wsDualHttpBinding,netTcpContextBinding,wsHttpContextBinding,basicHttpContextBinding,mexHttpBinding,mexHttpsBinding,mexHttpBinding,webHttpBinding‘。C:\DuplexService\DuplexService\Web.config

我无法将服务引用添加到客户端。我无法在WCF测试客户端中加载该服务。我在很多地方都找过答案。我不知道问题出在哪里。

当前的web.config如下所示:

代码语言:javascript
复制
<!-- Register the binding extension from the SDK. -->
<extensions>
  <bindingExtensions>
    <add name=
        "pollingDuplexHttpBinding"
        type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </bindingExtensions>
</extensions>

<bindings>
  <!-- Create the polling duplex binding. -->
  <pollingDuplexHttpBinding>
    <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
             duplexMode="MultipleMessagesPerPoll"
             maxOutputDelay="00:00:07"/>
  </pollingDuplexHttpBinding>
</bindings>

<services>
  <service name="DuplexService.OrderService"
     behaviorConfiguration="DuplexService.OrderServiceBehavior">

    <!-- Service Endpoints -->
    <endpoint
       address=""
       binding="pollingDuplexHttpBinding"
       bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
       contract="DuplexService.IDuplexService">
    </endpoint>
    <endpoint
        address="mex"
        binding="mexHttpBinding"
        contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

EN

回答 2

Stack Overflow用户

发布于 2012-03-27 09:26:57

我也有过这个问题。通过添加

代码语言:javascript
复制
C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll

对WebRole项目的引用。

票数 4
EN

Stack Overflow用户

发布于 2011-08-19 13:26:44

用这个配置..。对我来说很管用。

代码语言:javascript
复制
<system.serviceModel>
<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex"
         type="System.ServiceModel.Configuration.PollingDuplexElement, 
         System.ServiceModel.PollingDuplex" />
  </bindingElementExtensions>
</extensions>
<bindings>
  <customBinding>
    <binding name="pollingDuplexBinding">
      <binaryMessageEncoding />
      <pollingDuplex maxPendingSessions="2147483647"   
                     maxPendingMessagesPerSession="2147483647" 
                     />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="sb">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceThrottling maxConcurrentSessions="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="DataServices" behaviorConfiguration="sb" >
    <endpoint address="" 
              binding="customBinding" 
              bindingConfiguration="pollingDuplexBinding"
              contract="DataServices.IDataService"/>
    <endpoint address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange"/>
  </service>
</services>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5411187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档