NetNamedPipeBinding (Clase)
TOC
Collapse the table of content
Expand the table of content

NetNamedPipeBinding (Clase)

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

Espacio de nombres: System.ServiceModel
Ensamblado: System.ServiceModel (en system.servicemodel.dll)

public class NetNamedPipeBinding : Binding, IBindingRuntimePreferences
public class NetNamedPipeBinding extends Binding implements IBindingRuntimePreferences
public class NetNamedPipeBinding extends Binding implements IBindingRuntimePreferences
No aplicable.

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 NetNamedPipesBinding 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.

<bindings>
  <!-- 
        Following is the expanded configuration section for a NetNamedPipeBinding.
        Each property is configured with the default value.
     -->
  <netNamedPipeBinding>
    <binding name="Binding1" 
             hostNameComparisonMode="StrongWildcard" 
             maxBufferSize="65536"
             maxConnections="10"
             maxReceivedMessageSize="65536"
             receiveTimeout="00:10:00"
             transactionFlow="false">
      <security mode="Transport">
      </security>
    </binding>
  </netNamedPipeBinding>
</bindings>

The following shows how to programmatically use the NetNamedPipeBinding class:

[ServiceContract(Namespace = "http://UE.Samples")]
public interface ICalculator
{
    [OperationContract]
    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");
            serviceHost.Description.Behaviors.Add(smb);

    long maxBufferPoolSize = binding.MaxBufferPoolSize;

    int maxBufferSize = binding.MaxBufferSize;

    int maxConnections = binding.MaxConnections;

    long maxReceivedMessageSize =
        binding.MaxReceivedMessageSize;

    NetNamedPipeSecurity security = binding.Security;

    string scheme = binding.Scheme;

    XmlDictionaryReaderQuotas readerQuotas =
        binding.ReaderQuotas;

    BindingElementCollection bCollection = binding.CreateBindingElements();

    HostNameComparisonMode hostNameComparisonMode =
        binding.HostNameComparisonMode;

    bool TransactionFlow = binding.TransactionFlow;

    TransactionProtocol transactionProtocol =
        binding.TransactionProtocol;

    EnvelopeVersion envelopeVersion =
        binding.EnvelopeVersion;

    TransferMode transferMode =
        binding.TransferMode;


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

            serviceHost.Close();
        }
    }

static void SnippetReceiveSynchronously ()
{

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


}
}

System.Object
   System.ServiceModel.Channels.Binding
    System.ServiceModel.NetNamedPipeBinding

Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2016 Microsoft