Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Technology Samples
Basic Samples
Binding Samples
Net Binding Samples
 NetNamedPipeBinding
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
NetNamedPipeBinding

Download sample

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 Sample calculator service.

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

ms752247.Important(en-us,VS.90).gif Note:
The WCF samples may already be installed on your machine. Check this (default) directory before continuing: <InstallDrive>:\Samples\WCFWFCardspaceIf this directory doesn’t exist, click the download sample link at the top of this page. Note that this will download and install all of the WF, WCF, and CardSpace samples, you will only have to do this once. The sample is located in the following directory <InstallDrive>:\Samples\WCFWFCardSpace\WCF\Basic\Binding\Net\NamedPipe.

ms752247.note(en-us,VS.90).gifNote:
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> element as shown in the following sample configuration:

<endpoint address="net.pipe://localhost/ServiceModelSamples/service"
          binding="netNamedPipeBinding"
          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"
          binding="netNamedPipeBinding"
          bindingConfiguration="Binding1" 
          contract="Microsoft.ServiceModel.Samples.ICalculator" />

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

<bindings>
  <!-- 
        Following is the expanded configuration section for a NetNamedPipeBinding.
        Each property is configured with the default value.
     -->
  <netNamedPipeBinding>
    <binding name="Binding1" 
             closeTimeout="00:01:00"
             openTimeout="00:01:00" 
             receiveTimeout="00:10:00" 
             sendTimeout="00:01:00"
             transactionFlow="false" 
             transferMode="Buffered" 
             transactionProtocol="OleTransactions"
             hostNameComparisonMode="StrongWildcard" 
             maxBufferPoolSize="524288"
             maxBufferSize="65536" 
             maxConnections="10" 
             maxReceivedMessageSize="65536">
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netNamedPipeBinding>
</bindings>

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 Set Up 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.


© 2007 Microsoft Corporation. All rights reserved.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker