C# 如何将netTcpBinding转换为customBinding?

C# 如何将netTcpBinding转换为customBinding?,c#,wcf,wcf-binding,nettcpbinding,C#,Wcf,Wcf Binding,Nettcpbinding,我正在尝试将netTcpBinding转换为customBinding 下面是NetCPBinding的配置: <netTcpBinding> <binding name="DuplexBinding" sendTimeout="00:00:30" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <read

我正在尝试将netTcpBinding转换为customBinding

下面是NetCPBinding的配置:

<netTcpBinding>
    <binding name="DuplexBinding" sendTimeout="00:00:30" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      <reliableSession enabled="true" ordered="true"/>
      <security mode="Message">
        <message clientCredentialType="UserName"/>
      </security>                    
    </binding>
</netTcpBinding>

我已创建了一个CustomDuplexBinding

<customBinding>
    <binding name="CustomDuplexBinding" sendTimeout="00:00:30">
      <transactionFlow />
      <reliableSession ordered="true"/>
      <security authenticationMode="UserNameForCertificate" enableUnsecuredResponse="true">
        <secureConversationBootstrap authenticationMode="UserNameForCertificate" />
      </security>
      <compositeDuplex />
      <oneWay />
      <binaryMessageEncoding>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
                      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      </binaryMessageEncoding>
      <sslStreamSecurity requireClientCertificate="false"/>
      <tcpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
    </binding>
</customBinding>

但当我运行时,发生了以下异常:

绑定“CustomDuplexBinding”不支持创建任何通道类型。 这通常表示CustomBinding中的BindingElements具有 堆放不正确或顺序错误。交通工具是 在堆栈的底部需要。建议的订单 BindingElements是:TransactionFlow、ReliableSession、Security、, CompositedPlex、单向、StreamSecurity、MessageEncoding、传输

有人能帮我解决这个问题吗?

来自错误消息:“…StreamSecurity,MessageEncoding…”


在您的绑定配置中,您遇到了
我也遇到了同样的问题。虽然流安全性和消息编码元素在原始帖子中是向后的,但即使它们的顺序正确,也会发生相同的错误。对我来说,问题在于安全元素上使用的authenticationMode。我的nettcp安全元素与原始海报的相同(带有用户名验证的消息安全性)。使用该方法可以:

<security authenticationMode="SecureConversation">
   <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated" />
</security>


您是否尝试切换
的顺序?我尝试切换顺序,但出现异常:“在绑定“CustomBinding”中,TransportBindingElement“TcpTransportBindingElement”在BindingElementCollection中不会出现在最后。请更改元素的顺序,使TransportBindingElement成为最后一个。”我尝试了一些组合,但没有结果。所需的订单也不起作用。我已删除安全元素,服务已成功启动。我不知道保安有什么问题。谢谢你的帮助@Tim两周后我看到了你的帖子和粗体文字:RequiredOrder为我的wsHttp定制绑定拯救了我的生命!谢谢
<security authenticationMode="SecureConversation">
   <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated" />
</security>