如果是HTTP协议可以直接通过设计器生成异步,但是net.tcp协议在设计器中就无法生成了,请问它的异步怎么办?异步wcftcphttp协议

解决方案 »

  1.   

    你既然说了“HTTP协议可以直接通过设计器生成异步”,那就参考生成的代码,修改协议到netTcpBinding即可。
      

  2.   

    手动创建异步?
    不是WinRT平台下Silverlight平台下才有异步吗
      

  3.   

    没这么麻烦在宿主程序中,加入<serviceMetadata httpGetEnabled="true"/>然后再加个基地址就行了
    <?xml version="1.0"?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
    <system.serviceModel>
    <behaviors>
    <serviceBehaviors>
    <behavior name="MyBehavior">
    <serviceThrottling maxConcurrentSessions="10000" />
    <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
    <serviceMetadata httpGetEnabled="true"/>
    <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
    <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <bindings>
    <netTcpBinding>
    <binding name="DuplexBinding" sendTimeout="00:00:10">
    <security mode="None">
    <message clientCredentialType="Windows"/>
    </security>
    </binding>
    </netTcpBinding>
    </bindings>
    <services>
    <service name="WCFTCP.Service" behaviorConfiguration="MyBehavior">
    <endpoint address="net.tcp://localhost:1919/jhknfp" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="WCFTCP.IService">
    <identity>
    <dns value="localhost"/>
    </identity>
    </endpoint>
    <host>
    <baseAddresses>
    <add baseAddress="net.tcp://localhost:1919/jhknfp"/>
    <add baseAddress="http://localhost:1528/jhknfp"/>
    </baseAddresses>
    </host>
    </service>
    </services>
    </system.serviceModel>
    </configuration>