C# 使用TCP时收到错误:";无法发送该邮件…”;

C# 使用TCP时收到错误:";无法发送该邮件…”;,c#,wcf,tcp,C#,Wcf,Tcp,我不熟悉创建WCF服务。我在VS2008中创建了一个运行在IIS 7上的WCF web服务。当我使用http时,服务工作得非常好。当我为TCP配置服务并运行时,会收到以下错误消息 有一个沟通问题。这个 无法发送消息 因为端点处的服务 地址 “净额:tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc 对于的协议不可用 地址 我已经搜索了很多论坛,包括这一个,寻找一个解决方案,但没有任何效果。IIS 7上的所有设置似乎都正确。WAS已设置为运

我不熟悉创建WCF服务。我在VS2008中创建了一个运行在IIS 7上的WCF web服务。当我使用http时,服务工作得非常好。当我为TCP配置服务并运行时,会收到以下错误消息

有一个沟通问题。这个 无法发送消息 因为端点处的服务 地址 “净额:tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc 对于的协议不可用 地址

我已经搜索了很多论坛,包括这一个,寻找一个解决方案,但没有任何效果。IIS 7上的所有设置似乎都正确。WAS已设置为运行。默认网站具有net.tcp绑定,应用程序在启用的协议下具有net.tcp

我将包括我认为是主机项目中web.config的重要部分,以及用于测试服务的客户端项目中的app.config。希望有人能发现我的错误。提前感谢任何人提供的任何帮助或建议

Web.Config

<bindings>
   <wsHttpBinding>
      <binding name="wsHttpBindingNoMsgs">
         <security mode="None" />
       </binding>
   </wsHttpBinding>
</bindings>
<services>
   <service behaviorConfiguration="CogIDServiceHost.ServiceBehavior"
           name="CogIDServiceLibrary.CogIdService">
      <endpoint address="" 
                binding="wsHttpBinding" 
                bindingConfiguration="wsHttpBindingNoMsgs"
                contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                contract="IMetadataExchange" />
      <endpoint name="CoordinateIdService_TCP"
          address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" 
          contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
    </service>
 </services>
 <behaviors>
    <serviceBehaviors>
       <behavior name="CogIDServiceHost.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
       </behavior>
    </serviceBehaviors>
 </behaviors>
<system.serviceModel>
    <diagnostics performanceCounters="Off">
        <messageLogging logEntireMessage="true" logMalformedMessages="false"
            logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" />
    </diagnostics>
    <behaviors />
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_CogIdTool" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        establishSecurityContext="true" />
                </security>
            </binding>
            <binding name="wsHttpBindingNoMsg">
                <security mode="None">
                    <transport clientCredentialType="Windows" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://sdet/CogId_WCF/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="wsHttpBindingNoMsg" contract="CogIdServiceReference.CogIdTool"
            name="IISHostWsHttpBinding">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://localhost:1890/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_CogIdTool" contract="CogIdServiceReference.CogIdTool"
            name="WSHttpBinding_CogIdTool">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://elec/CoordinateIdTool/IdToolService.svc"
            binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoMsg"
            contract="CogIdServiceReference.CogIdTool" name="IIS7HostWsHttpBinding_Elec">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
      <endpoint address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" contract="CogIdServiceReference.CogIdTool"
            name="IIS7HostTcpBinding_Elec" >
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
    </client>
</system.serviceModel>

App.Config

<bindings>
   <wsHttpBinding>
      <binding name="wsHttpBindingNoMsgs">
         <security mode="None" />
       </binding>
   </wsHttpBinding>
</bindings>
<services>
   <service behaviorConfiguration="CogIDServiceHost.ServiceBehavior"
           name="CogIDServiceLibrary.CogIdService">
      <endpoint address="" 
                binding="wsHttpBinding" 
                bindingConfiguration="wsHttpBindingNoMsgs"
                contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                contract="IMetadataExchange" />
      <endpoint name="CoordinateIdService_TCP"
          address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" 
          contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
    </service>
 </services>
 <behaviors>
    <serviceBehaviors>
       <behavior name="CogIDServiceHost.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
       </behavior>
    </serviceBehaviors>
 </behaviors>
<system.serviceModel>
    <diagnostics performanceCounters="Off">
        <messageLogging logEntireMessage="true" logMalformedMessages="false"
            logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" />
    </diagnostics>
    <behaviors />
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_CogIdTool" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        establishSecurityContext="true" />
                </security>
            </binding>
            <binding name="wsHttpBindingNoMsg">
                <security mode="None">
                    <transport clientCredentialType="Windows" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://sdet/CogId_WCF/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="wsHttpBindingNoMsg" contract="CogIdServiceReference.CogIdTool"
            name="IISHostWsHttpBinding">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://localhost:1890/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_CogIdTool" contract="CogIdServiceReference.CogIdTool"
            name="WSHttpBinding_CogIdTool">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://elec/CoordinateIdTool/IdToolService.svc"
            binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoMsg"
            contract="CogIdServiceReference.CogIdTool" name="IIS7HostWsHttpBinding_Elec">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
      <endpoint address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" contract="CogIdServiceReference.CogIdTool"
            name="IIS7HostTcpBinding_Elec" >
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
    </client>
</system.serviceModel>

你看过这个MSDN论坛帖子吗


我想我的问题与你的问题相似。我所做的是,我去了WCF webservice的站点,而不是应用程序池,进入高级设置,从启用的协议中删除了net.tcp,点击ok,保存了设置,称为net.tcp服务,它当然给了我股票异常

 Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. 
然后,我将net.tcp重新添加到启用的协议中。然后,web服务运行得非常好。
我不知道为什么会这样。我认为它强制重新设置了TCP侦听器。不过,我不能确定。

我试过那条线,但不起作用。现在我收到错误消息“请求的服务net.tcp//elec:9090/CoordinatedTool_tcp/IdToolService.svc无法激活”。我遇到了类似的情况,在添加net.tcp条目后,我不得不循环应用程序池以使其正常运行。谢谢你,这真的很有帮助。太奇怪了。