title: WCF named pipe minimal example
body: <p>I'm looking for minimal example of WCF Named Pipes (I expect two minimal applications, server and client, which can communicate via a named pipe.)</p>
  
  <p>Microsoft has the briliant article <em><a href="http://msdn.microsoft.com/en-us/library/ms734712.aspx">Getting Started Tutorial</a></em> that describes WCF via HTTP, and I'm looking for something similar about WCF and named pipes.</p>
  
  <p>I've found several posts in the Internet, but they are a little bit "advanced". I need something minimal, only mandatory functionality, so I can add my code and get the application working.</p>
  
  <p>How do I replace that to use a named pipe?</p>
  
  <pre><code>&lt;endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
      contract="ICalculator" name="WSHttpBinding_ICalculator"&gt;
      &lt;identity&gt;
          &lt;userPrincipalName value="OlegPc\Oleg" /&gt;
      &lt;/identity&gt;
  &lt;/endpoint&gt;
  </code></pre>
  
  <p>How do I replace that to use a named pipe?</p>
  
  <pre><code>// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
  Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");
  
  // Step 2 of the hosting procedure: Create ServiceHost
  ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
  
  try
  {
      // Step 3 of the hosting procedure: Add a service endpoint.
      selfHost.AddServiceEndpoint(
          typeof(ICalculator),
          new WSHttpBinding(),
          "CalculatorService");
  
      // Step 4 of the hosting procedure: Enable metadata exchange.
      ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
      smb.HttpGetEnabled = true;
      selfHost.Description.Behaviors.Add(smb);
  
      // Step 5 of the hosting procedure: Start (and then stop) the service.
      selfHost.Open();
      Console.WriteLine("The service is ready.");
      Console.WriteLine("Press &lt;ENTER&gt; to terminate service.");
      Console.WriteLine();
      Console.ReadLine();
  
      // Close the ServiceHostBase to shutdown the service.
      selfHost.Close();
  }
  catch (CommunicationException ce)
  {
      Console.WriteLine("An exception occurred: {0}", ce.Message);
      selfHost.Abort();
  }
  </code></pre>
  
  <p>How do I generate a client to use a named pipe?</p>