title: WCF Named Pipe Error: The pipe has been ended. (109, 0x6d)
body: <p>I have looked at the other posts dealing with "The pipe has been ended. (109, 0x6d)" but none of them have solved my problem. I have a relatively simple setup bases off of this blog: <a href="http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication" rel="nofollow">http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication</a></p>
  
  <p>I feel like I follow it pretty closely, only removing the HTTP binding. </p>
  
  <p>Here is the server code:</p>
  
  <pre><code>public class InterProcessServer : IInterProcessServer 
  {
      private ServiceHost _host = null;
  
      public event EventHandler&lt;CommandLineArgsEventArgs&gt; CommandLineArgsReceived;
  
      protected InterProcessServer(Uri serverAddress, string serviceName)
      {
          IPassCommandLineArgs passArgs = null;
          passArgs = CreatePassCommandLineArgs();
          passArgs.CommandLineArgsReceived += new EventHandler&lt;CommandLineArgsEventArgs&gt; passArgs_CommandLineArgsReceived);
  
          _host = new ServiceHost(passArgs, new Uri[] { serverAddress });
          _host.AddServiceEndpoint(typeof(IPassCommandLineArgs), new NetNamedPipeBinding(), serviceName);
          _host.Open();
      }
  
      public static IInterProcessServer CreateInterProcessServer(Uri serverAddress, string serviceName)
      {
          return new InterProcessServer(serverAddress, serviceName);
      }
  
      public void Dispose()
      {
          try
          {
              _host.Close();
          }
          catch { }
      }
  
      private void passArgs_CommandLineArgsReceived(object sender, CommandLineArgsEventArgs e)
      {
          EventHandler&lt;CommandLineArgsEventArgs&gt; handler = CommandLineArgsReceived;
  
          if (handler != null)
              handler(sender, e);
      }
  
      protected virtual IPassCommandLineArgs CreatePassCommandLineArgs()
      {
          return new PassCommandLineArgs();
      }
  }
  </code></pre>
  
  <p>Here is the client code:</p>
  
  <pre><code>public class InterProcessClient : IInterProcessClient
  {
      private IPassCommandLineArgs _pipeProxy = null;
      private ChannelFactory&lt;IPassCommandLineArgs&gt; _pipeFactory = null;
  
      protected InterProcessClient(Uri serviceAddress)
      {
          _pipeFactory = new ChannelFactory&lt;IPassCommandLineArgs&gt;(new NetNamedPipeBinding(), new EndpointAddress(serviceAddress));
          _pipeProxy = _pipeFactory.CreateChannel();
      }
  
      public static IInterProcessClient CreateInterProcessClient(Uri serviceAddress)
      {
          return new InterProcessClient(serviceAddress);
      }
  
      public void SendArgs(string[] args)
      {
          _pipeProxy.PassArgs(args);           
      }
  
  
      public void Dispose()
      {
          try
          {
              if (_pipeFactory != null)
                  _pipeFactory.Close();
          }
          catch { }
      }
  }
  </code></pre>
  
  <p>I have ensured that the address the client is connecting to is correct. Can anyone provide an idea why I might be getting the error when <code>_pipeProxy.PassArgs(args);</code> is called from the client? The test is just between two console apps on the same machine running in different processes.</p>
  
  <p>Framework 4.0 btw.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong> Here is the service interface and implementation:</p>
  
  <pre><code>[ServiceContract]
  public interface IPassCommandLineArgs
  {
      event EventHandler&lt;CommandLineArgsEventArgs&gt; CommandLineArgsReceived;
  
      [OperationContract]
      void PassArgs(string[] args);
  }
  
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  public class PassCommandLineArgs : IPassCommandLineArgs
  {
      public event EventHandler&lt;CommandLineArgsEventArgs&gt; CommandLineArgsReceived;
  
      public void PassArgs(string[] args)
      {
          EventHandler&lt;CommandLineArgsEventArgs&gt; hander = CommandLineArgsReceived;
  
          if (hander != null)
              hander(this, new CommandLineArgsEventArgs() { Args = args });
      }
  }
  </code></pre>