使用自定义 tcp 绑定

Using custom tcp bindings

我有一个自定义 tcp 绑定,我想在服务上测试,特别是为了禁用安全性:

<bindings>
  <netTcpBinding>
    <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
      <security mode="None"></security>
    </binding>
  </netTcpBinding>
</bindings>

但是,在配置中使用 tcp 绑定的名称时,我收到此错误:

    Severity    Code    Description Project File    Line
Warning     The 'binding' attribute is invalid - The value 'customTcpBinding' is invalid according to its datatype 'serviceBindingType' - The Enumeration constraint failed.    Server  C:\Users\Totally Not Beau\documents\visual studio 2015\Projects\WCF Proj\WCF Proj\App.config    24

端点配置:

        <endpoint 
          address="" 
          binding="customTcpBinding" 
          bindingConfiguration="" 
          contract="Server.IMyService">
        </endpoint>

整个文件如果有帮助的话:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
   <behaviors>
      <serviceBehaviors>
         <behavior name="">
            <serviceMetadata httpGetEnabled="false" />
            <serviceDebug includeExceptionDetailInFaults="false" />
         </behavior>
      </serviceBehaviors>
   </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>
   <services>
       <service name="Server.MyService">
           <endpoint address="" binding="customTcpBinding" bindingConfiguration=""
               contract="Server.IMyService">
           </endpoint>
           <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
               contract="IMetadataExchange" />
           <host>
               <baseAddresses>
                   <add baseAddress="net.tcp://192.168.2.7:8732/MyService/" />
               </baseAddresses>
           </host>
       </service>
   </services>
</system.serviceModel>
</configuration>

如有任何建议,我们将不胜感激!

我想你想要的是

<endpoint 
  address="" 
  binding="netTcpBinding" 
  bindingConfiguration="customTcpBinding" 
  contract="Server.IMyService">
</endpoint>

您可能还必须指定一个实际地址,我不确定。