C# – Unable to access WCF service using NET.TCP binding

cnetsocketstcpwcf

I already asked a similar question here: Unable to add service client for a net.tcp WCF service. The problem was solved at that time. But now the same error is coming up. My configuration of WCF service is same as that of previous question. I am again posting it here:

<system.serviceModel>
    <services>
      <service name="CoreService.Service1" behaviorConfiguration="beh1">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost/Service1.svc/mex" />
          </baseAddresses>
        </host>
        <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IAccountService"/>
        <endpoint
      binding="netTcpBinding"
      bindingConfiguration="ultra"
      contract="CoreService.IBoardService"/>
        <endpoint
      binding="netTcpBinding"
      bindingConfiguration="ultra"
      contract="CoreService.ICategoryService"/>

        <endpoint
                address="mex"
                binding="mexTcpBinding"
                contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="ultra"
             maxBufferPoolSize="2147483647"
             maxBufferSize="2147483647"
             maxReceivedMessageSize="2147483647"
             portSharingEnabled="false"
             transactionFlow="false"
             listenBacklog="2147483647"
             sendTimeout="00:01:00">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport protectionLevel="None" clientCredentialType="None"/>
          </security>
          <reliableSession enabled="false"/>
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="beh1">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <dataContractSerializer maxItemsInObjectGraph="65536" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

The error is:

The URI prefix is not recognized. Metadata contains a reference that
cannot be resolved: 'net.tcp://localhost/Service1.svc'. Could not
connect to net.tcp://localhost/Service1.svc. The connection attempt
lasted for a time span of 00:00:02.0051147. TCP error code 10061: No
connection could be made because the target machine actively refused
it 127.0.0.1:808. No connection could be made because the target
machine actively refused it 127.0.0.1:808 If the service is defined in
the current solution, try building the solution and adding the service
reference again.

After the problem was solved, I didn't made any changes to the configuration and after some days it started showing that error again. I tried everything but nothing worked. Please help!

UPDATE: I am also able to access it using HTTP through my browser but unable to access using "Add Service Reference" option through net.tcp protocol.

Best Answer

Finally with the help of this link: http://rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/, I figured out what was going wrong. Actually I missed the third step in above link. The Net.Tcp services were not running.

enter image description here

Related Topic