title: WCF TCP Endpoints Cannot Add Service Reference
body: <p>I've been battling with this one for weeks in my spare-time, determined not to turn to this wonderful community. But my spirit is broken. So ...</p>
  
  <p>I have created a WCF Service and am trying to host it in a Console App, with a view to using a TCP end point.</p>
  
  <p>I have one project which contains the contract and the svc file.
  I have another project which contains a Console app, which references the first-mentioned project.
  The main method of my Console app looks like this:</p>
  
  <pre><code>using (ServiceHost host = new ServiceHost(typeof(LicenceBucketWireService.LicenceBucketService)))
  {
      host.Open();
  
      foreach (var endpt in host.Description.Endpoints)
      {
          Console.WriteLine("Enpoint address:\t{0}",endpt.Address);
          Console.WriteLine("Enpoint binding:\t{0}",endpt.Binding);
          Console.WriteLine("Enpoint contract:\t{0}\n", endpt.Contract.ContractType.Name);
      }
      Console.ReadLine();
  }
  </code></pre>
  
  <p>Up til this point, all is dandy:</p>
  
  <p><img src="https://i.stack.imgur.com/KdNlp.png" alt="enter image description here"></p>
  
  <p>It goes awry when I try to add a Service Reference for that service to a 3rd completely separate app which is going to consume that service. When I try to add a reference, using net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex as the address for discovering details, I get an error:</p>
  
  <blockquote>
    <p>The URI prefix is not recognized.
    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'.
    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'.
    If the service is defined in the current solution, try building the solution and adding the service reference again.</p>
  </blockquote>
  
  <p>The console app is running when I perform this task.
  The app config has the following element:</p>
  
  <pre><code>  &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="LicenceBucketWireService.LicenceBucketService"&gt;
          &lt;clear /&gt;
          &lt;endpoint address="mex" binding="mexTcpBinding" contract="LicenceBucketWireService.ILicenceBucketService"
            listenUriMode="Explicit"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="net.pipe://localhost/licenceBucketService"
            binding="netNamedPipeBinding" bindingConfiguration="" contract="LicenceBucketWireService.ILicenceBucketService" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:49187/LicenceBucketWireService/LicenceBucketService" /&gt;
              &lt;add baseAddress="net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;    
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
            &lt;!-- 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 --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>