wcf net.tcp绑定引发错误URI前缀无法识别,http绑定正常

wcf net.tcp绑定引发错误URI前缀无法识别,http绑定正常,wcf,net.tcp,Wcf,Net.tcp,我有一个简单的wcf服务,托管在运行windows7的本地计算机上的IIS 7中,带有nettcp绑定,我正在尝试使用winform访问该绑定,但无论我尝试什么,都会收到相同的错误。不过,我可以通过http访问该服务 在这一点上,我花了一整天的时间试图找出原因,并且已经阅读了关于堆栈溢出主题的大部分文章。在这一点上,我觉得我缺少一些基本的东西,任何来自专家的反馈都是非常感谢的 即使您指导我如何调试,或者在何处查找确切原因,这将非常有帮助,因为我在事件日志或失败的请求跟踪中没有看到任何有用的内容:

我有一个简单的wcf服务,托管在运行windows7的本地计算机上的IIS 7中,带有nettcp绑定,我正在尝试使用winform访问该绑定,但无论我尝试什么,都会收到相同的错误。不过,我可以通过http访问该服务

在这一点上,我花了一整天的时间试图找出原因,并且已经阅读了关于堆栈溢出主题的大部分文章。在这一点上,我觉得我缺少一些基本的东西,任何来自专家的反馈都是非常感谢的

即使您指导我如何调试,或者在何处查找确切原因,这将非常有帮助,因为我在事件日志或失败的请求跟踪中没有看到任何有用的内容:(

我已采取的步骤

  • 在启用net.tcp的localhost上设置一个新网站(不带空格)
  • 确保net.tcp的所有三个服务都在运行
  • 已禁用webconfig中的安全性(无而不是windows)
  • 我的服务详情

    namespace WcfService1
    {
       public class Service1 : IService1
        {
            public string Echo(string msg)
            {
                return DateTime.Now.ToString();
            }
        }
    }
    
    网络配置

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding" contract="WcfService1.IService1" >
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:820/Service1.svc"/>
              </baseAddresses>
            </host>
          </service>
        </services>
        <bindings>
          <netTcpBinding>
            <binding name="tcpBinding" portSharingEnabled="true">
              <security mode="None"></security>
            </binding>
          </netTcpBinding>
        </bindings>
        <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="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <!--<protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>-->    
    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>
    
    </configuration>
    

    是否通过引用-->服务引用添加引用?我使用了您的web配置文件,并成功运行和使用了控制台应用程序的WCF服务。

    对此表示怀疑,但您可以尝试取消对
    部分的注释并添加
    。另外,请查看IIS日志和事件视图r查看那里是否有任何信息。谢谢你的建议tim,我已经尝试过了,但是goanna查看iis日志,看看我是否找到了nything。你好,Aditya,我正在将其添加为服务参考。让我问你,你是在iis中本地托管服务,还是作为解决方案的一部分?你有作为库或应用程序的服务吗ion?我将服务作为wcf服务应用程序,而不是库我将其作为应用程序,并在IIS中本地托管。
    The URI prefix is not recognized.
    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:820/Service1.svc'.
    The requested service, 'net.tcp://localhost:820/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information.
    If the service is defined in the current solution, try building the solution and adding the service reference again.