NetNamedPipeBinding Class

Provides a secure and reliable binding that is optimized for on-machine communication.

Namespace: System.ServiceModel
Assembly: System.ServiceModel (in system.servicemodel.dll)

public class NetNamedPipeBinding : Binding, IBindingRuntimePreferences
public class NetNamedPipeBinding extends Binding implements IBindingRuntimePreferences
public class NetNamedPipeBinding extends Binding implements IBindingRuntimePreferences
Not applicable.

The NetNamedPipeBinding generates a run-time communication stack by default, which uses transport security, Named Pipes for message delivery, and a binary message encoding. This binding is an appropriate Windows Communication Foundation (WCF) out-of-the-box choice for on-machine communication. It also supports transactions.

The default configuration for the NetNamedPipeBinding is similar to the configuration provided by the NetTcpBinding, but it is simpler because the WCF implementation is only meant for on-machine use and consequently there are fewer exposed features. The most notable difference is that the SecurityMode setting only offers the None and Transport options. SOAP security support is not an included option. The security behavior is configurable using the optional securityMode parameter in NetNamedPipeBinding(NetNamedPipeSecurityMode) the constructor.

The following shows the part of the configuration file that contains the section for the NetNamedPipeBinding with values set to defaults.

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

The following shows how to programmatically use the NetNamedPipeBinding class:

[ServiceContract(Namespace = "http://UE.Samples")]
public interface ICalculator
    double Add(double n1, double n2);

// Service class which implements the service contract.
public class CalculatorService : ICalculator
    public double Add(double n1, double n2)
        return n1 + n2;

    public static void Main()
        Uri baseAddress = new Uri("http://localhost:8000/uesamples/service");
        string address = "net.pipe://localhost/uesamples/calc";

        // Create a ServiceHost for the CalculatorService type and provide the base address.
        using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
            NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
            serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);

            // Add a mex endpoint
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.HttpGetUrl = new Uri("http://localhost:8001/uesamples");

    long maxBufferPoolSize = binding.MaxBufferPoolSize;

    int maxBufferSize = binding.MaxBufferSize;

    int maxConnections = binding.MaxConnections;

    long maxReceivedMessageSize =

    NetNamedPipeSecurity security = binding.Security;

    string scheme = binding.Scheme;

    XmlDictionaryReaderQuotas readerQuotas =

    BindingElementCollection bCollection = binding.CreateBindingElements();

    HostNameComparisonMode hostNameComparisonMode =

    bool TransactionFlow = binding.TransactionFlow;

    TransactionProtocol transactionProtocol =

    EnvelopeVersion envelopeVersion =

    TransferMode transferMode =

            Console.WriteLine("The service is ready.");
            Console.WriteLine("Press <ENTER> to terminate service.");


static void SnippetReceiveSynchronously ()

    NetNamedPipeBinding binding = new NetNamedPipeBinding();
    IBindingRuntimePreferences s  =
           (new BindingParameterCollection());
    bool receiveSynchronously = s.ReceiveSynchronously;



Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0