This sample demonstrates the netNamedPipeBinding binding, which provides cross-process communication on the same machine. Named pipes do not work across machines. This sample is based on The Getting Started calculator service.

In this sample, the service is self-hosted. Both the client and the service are console applications.


The setup procedure and build instructions for this sample are located at the end of this topic.

The binding is specified in the configuration files for the client and service. The binding type is specified in the binding attribute of the <endpoint> or <endpoint> of <client> element, as shown in the following sample configuration:

<endpoint address="net.pipe://localhost/ServiceModelSamples/service"  
          contract="Microsoft.ServiceModel.Samples.ICalculator" />  

The previous sample shows how to configure an endpoint to use the netNamedPipeBinding binding with the default settings. If you want to configure the netNamedPipeBinding binding and change some of its settings, you must define a binding configuration. The endpoint must reference the binding configuration by name with a bindingConfiguration attribute.

<endpoint address="net.pipe://localhost/ServiceModelSamples/service"  
          contract="Microsoft.ServiceModel.Samples.ICalculator" />  

In this sample, the binding configuration is named Binding1 and has the following definition:

        Following is the expanded configuration section for a NetNamedPipeBinding.  
        Each property is configured with the default value.  
    <binding name="Binding1"
      <security mode="Transport">  
        <transport protectionLevel="EncryptAndSign" />  

When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.

Add(100,15.99) = 115.99  
Subtract(145,76.54) = 68.46  
Multiply(9,81.25) = 731.25  
Divide(22,7) = 3.14285714285714  
Press <ENTER> to terminate client.  

To set up, build, and run the sample

  1. Ensure that you have performed the One-Time Setup Procedure for the Windows Communication Foundation Samples.

  2. To build the C# or Visual Basic .NET edition of the solution, follow the instructions in Building the Windows Communication Foundation Samples.

  3. To run the sample in a single machine configuration, follow the instructions in Running the Windows Communication Foundation Samples.


The samples may already be installed on your machine. Check for the following (default) directory before continuing.


If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.