This documentation is archived and is not being maintained.

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 extends Binding implements IBindingRuntimePreferences

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) system-provided 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 example 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 example 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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0