找不到与具有绑定 NetTcpBinding 的终结点的方案 net.tcp 匹配的基地址。基址方案是 [http]

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Base address schemes are [http]

我的 WCF 服务有此配置,它 运行 在 IIS Express 端口号 50187 上。该服务托管在 Visual Studio 2017 年的 IIS Express 上:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="QCConsumerBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="50000000" maxBufferPoolSize="5242880" maxReceivedMessageSize="50000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="QCWCFService.QCService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="QCConsumerBinding" contract="QCWCFService.IQCService" />
      </service>
      <service name="QCWCFService.QCFinalService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="QCConsumerBinding" contract="QCWCFService.IQCFinalService" />
      </service>

      <service name="QCWCFService.CalibrationService">
        <endpoint address="service" binding="netTcpBinding" contract="QCWCFService.ICalibrationService" />
        <endpoint address="" binding="wsDualHttpBinding" contract="QCWCFService.ICalibrationService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8080/CalibrationService" />
            <add baseAddress="http://localhost:8081/CalibrationService" />
          </baseAddresses>

        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>          
          <!-- To avoid disclosing metadata information, set the values below to false 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="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add scheme="http" binding="wsDualHttpBinding" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

但是当我尝试 运行 服务时,它给出了这个异常:

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

虽然我有另一个应用程序具有相同的双 Http 绑定配置,但它运行良好

默认情况下,IIS express 不支持 Net.tcp 协议。 Nettcpbinding 的服务端点需要一个基于 NetTcp 协议的基地址。

<endpoint address="service" binding="netTcpBinding" contract="QCWCFService.ICalibrationService" />

虽然我们使用Host Section提供了一个Nettcp基地址,但它不会起作用。这是因为 IIS express 使用自配置为 运行 当前项目提供基地址。 IIS express的配置通常位于当前Solution的.vs文件夹中,名为applicationhost.config

如果我们 运行 在具有此配置的控制台应用程序中使用此项目,它将起作用。因此,我们应该为 Nettcp 协议提供一个基地址。这可以在 IIS 中完成。
1. 为 net.tcp 协议启用 windows 功能。

2. 网站增加Net.tcp支持

3.在site binding module.
中添加net.tcp协议
为网站添加net.tcp协议的详情请参考下文。

如果问题仍然存在,请随时告诉我。