WCF service named pipe failure
<p>I've searched thoroughly, and found several answers to this problem, but none of them apply.</p>

<p>I have a .NET 4.0 WCF service hosted by windows services using a named pipe endpoint.  This is set to start automatically on boot.  I have a client that consumes the service.</p>

<p>When the server is rebooted, the service will start normally, but the client will get the following error:</p>

<p>1: There was no endpoint listening at net.pipe://localhost/WCFSQLService/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.</p>

<p>2: The pipe endpoint 'net.pipe://localhost/WCFSQLService/' could not be found on your local machine. </p>

<p>If the client and service are both restarted, the problem resolves itself.</p>

<p>As others have pointed out, both the Net.Pipe Listener Adapter is running and the WCF Non-HTTP Activation is checked:</p>

<p><img src="https://i.stack.imgur.com/avZuT.png" alt="net.pipe listener adapter"></p>

<p><img src="https://i.stack.imgur.com/3kzJU.png" alt="wcf non-http activation"></p>

<p>We've even tried setting the service to delayed start, but no joy.  One would assume it was something wrong with the endpoint or config or normal WCF stuff, but when the service and client are both restarted everything works.  Additionally, this only happens on 1 machine.  If necessary I can provide endpoint information and code.</p>

<p><strong>Client:</strong></p>

<pre><code>NetNamedPipeBinding binding = new NetNamedPipeBinding();
EndpointAddress endpoint = new EndpointAddress(endpointAddress);
ChannelFactory&lt;IWCFSQLService&gt; channel = new ChannelFactory&lt;IWCFSQLService&gt;(binding, endpoint);
IWCFSQLService client = channel.CreateChannel();
// do client calls
channel.Close();
</code></pre>

<p><strong>Host</strong></p>

<pre><code>  class Program
  {
    static void Main(string[] args)
    {
      ServiceBase[] servicesToRun = new ServiceBase[] 
        {
          new WinServiceHost(), 
        };


      ServiceBase.Run(servicesToRun);
    }
  }



  public class WinServiceHost : ServiceBase
  {
    private readonly ServiceManager serviceManager = new ServiceManager();

    protected override void OnStart(string[] args)
    {
      base.OnStart(args);

      serviceManager.OpenHost&lt;MyService&gt;();
    }

    protected override void OnStop()
    {
      base.OnStop();

      serviceManager.CloseAll();
    }
  }

  public class ServiceManager
  {
    private readonly List&lt;ServiceHost&gt; serviceHosts = new List&lt;ServiceHost&gt;();

    public void CloseAll()
    {
      foreach (ServiceHost serviceHost in serviceHosts)
      {
        serviceHost.Close();
      }
    }

    public void OpenHost&lt;T&gt;()
    {
      Type type = typeof(T);
      ServiceHost serviceHost = new ServiceHost(type);
      serviceHost.Open();
      serviceHosts.Add(serviceHost);
    }
  }
</code></pre>

<p><strong>config</strong></p>

<pre><code>  &lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service behaviorConfiguration="behaviorConfig" name="MyService"&gt;
        &lt;endpoint address="" binding="netNamedPipeBinding" bindingConfiguration="clientNamedPipeBinding"
                  contract="IMyService"&gt;
          &lt;identity&gt;
            &lt;dns value="localhost" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress="net.pipe://localhost/MyService" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
      &lt;/service&gt;
    &lt;/services&gt;
    &lt;bindings&gt;
      &lt;netNamedPipeBinding&gt;
        &lt;binding name="clientNamedPipeBinding"&gt;
          &lt;readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" /&gt;
        &lt;/binding&gt;
      &lt;/netNamedPipeBinding&gt;
    &lt;/bindings&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="behaviorConfig"&gt;
          &lt;serviceMetadata httpGetEnabled="false" httpGetUrl="" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="true" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="SuccessOrFailure" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
</code></pre>