NetNamedPipeBinding 类

定义

提供一个既安全又可靠且针对计算机上的通信进行了优化的绑定。Provides a secure and reliable binding that is optimized for on-machine communication.

public ref class NetNamedPipeBinding : System::ServiceModel::Channels::Binding, System::ServiceModel::Channels::IBindingRuntimePreferences
public class NetNamedPipeBinding : System.ServiceModel.Channels.Binding, System.ServiceModel.Channels.IBindingRuntimePreferences
type NetNamedPipeBinding = class
    inherit Binding
    interface IBindingRuntimePreferences
Public Class NetNamedPipeBinding
Inherits Binding
Implements IBindingRuntimePreferences
继承
NetNamedPipeBinding
实现

示例

下面的示例显示配置文件的一部分,其中包含值设置为默认值的 NetNamedPipeBinding 的节。The following example shows the part of the configuration file that contains the section for the NetNamedPipeBinding with values set to defaults.

下面的示例演示如何以编程方式使用 NetNamedPipeBinding 类。The following example 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;


}
}

注解

默认情况下,NetNamedPipeBinding 会生成一个运行时通信堆栈,该堆栈可使用传输安全、用于消息传递的命名管道和二进制消息编码。The NetNamedPipeBinding generates a run-time communication stack by default, which uses transport security, named pipes for message delivery, and a binary message encoding. 此绑定是 Windows Communication Foundation (WCF) 系统提供的一个相应选项,可用于计算机上的通信。This binding is an appropriate Windows Communication Foundation (WCF) system-provided choice for on-machine communication. 它还支持事务。It also supports transactions.

NetNamedPipeBinding 的默认配置与 NetTcpBinding 所提供的配置类似,但要简单一些,因为 WCF 实现仅计划在计算机上使用,因此公开的功能就更少。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. 其中最显著的差异在于 SecurityMode 设置只提供 NoneTransport 选项。The most notable difference is that the SecurityMode setting only offers the None and Transport options. 不包括 SOAP 安全支持选项。SOAP security support is not an included option. 安全行为可通过在 securityMode 构造函数中使用可选的 NetNamedPipeBinding(NetNamedPipeSecurityMode) 参数进行配置。The security behavior is configurable using the optional securityMode parameter in NetNamedPipeBinding(NetNamedPipeSecurityMode) the constructor.

构造函数

NetNamedPipeBinding()

初始化 NetNamedPipeBinding 类的新实例。Initializes a new instance of the NetNamedPipeBinding class.

NetNamedPipeBinding(NetNamedPipeSecurityMode)

使用指定的安全模式初始化 NetNamedPipeBinding 类的新实例。Initializes a new instance of the NetNamedPipeBinding class with a specified security mode.

NetNamedPipeBinding(String)

使用指定配置名称初始化 NetNamedPipeBinding 类的新实例。Initializes a new instance of the NetNamedPipeBinding class with a specified configuration name.

属性

CloseTimeout

获取或设置在传输引发异常之前可用于关闭连接的时间间隔。Gets or sets the interval of time provided for a connection to close before the transport raises an exception.

(继承自 Binding)
EnvelopeVersion

获取此绑定处理的消息将要使用的 SOAP 版本。Gets the version of SOAP that is used for messages processed by this binding.

HostNameComparisonMode

获取或设置一个值,该值指示在对 URI 进行匹配时,是否使用主机名来访问服务。Gets or sets a value that indicates whether the hostname is used to reach the service when matching the URI.

MaxBufferPoolSize

获取或设置内存中用于对传入消息进行缓冲的最大字节数。Gets or sets the maximum number of bytes that are used to buffer incoming messages in memory.

MaxBufferSize

获取或设置内存中用于对传入消息进行缓冲的最大字节数。Gets or sets the maximum number of bytes used to buffer incoming messages in memory.

MaxConnections

获取或设置入站和出站的最大连接数,这些连接是配置了命名管道绑定的终结点所允许的。Gets or sets the maximum number of connections, both inbound and outbound, that are allowed to endpoints configured with the named pipe binding.

MaxReceivedMessageSize

获取或设置绑定可处理的消息最大接收字节大小。Gets or sets the maximum size, in bytes, for a received message that is processed by the binding.

MessageVersion

获取由绑定所配置的客户端和服务使用的消息版本。Gets the message version used by clients and services configured with the binding.

(继承自 Binding)
Name

获取或设置绑定的名称。Gets or sets the name of the binding.

(继承自 Binding)
Namespace

获取或设置绑定的 XML 命名空间。Gets or sets the XML namespace of the binding.

(继承自 Binding)
OpenTimeout

获取或设置在传输引发异常之前可用于打开连接的时间间隔。Gets or sets the interval of time provided for a connection to open before the transport raises an exception.

(继承自 Binding)
ReaderQuotas

获取或设置可由配置了此绑定的终结点处理的 SOAP 消息的复杂性约束。Gets or sets constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding.

ReceiveTimeout

获取或设置连接在撤消之前保持非活动状态的最大时间间隔,在此时间间隔内未接收任何应用程序消息。Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped.

(继承自 Binding)
Scheme

获取用此绑定配置的通道和侦听器的 URI 传输方案。Gets the URI transport scheme for the channels and listeners that are configured with this binding.

Security

获取一个对象,该对象指定与采用此绑定配置的服务一起使用的安全类型。Gets an object that specifies the type of security used with services configured with this binding.

SendTimeout

获取或设置在传输引发异常之前可用于完成写入操作的时间间隔。Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception.

(继承自 Binding)
TransactionFlow

获取或设置一个值,该值指定事务是否应流动到服务。Gets or sets a value that determines whether transactions should be flowed to the service.

TransactionProtocol

获取或设置服务在对事务进行流处理时使用的事务处理协议。Gets or sets the transactions protocol used by the service to flow transactions.

TransferMode

获取或设置一个值,该值指示采用此绑定配置的服务是使用消息传输的流处理模式(单向或双向),还是缓冲模式。Gets or sets a value that indicates whether the service configured with the binding uses streamed (in one or both directions) or buffered modes of message transfer.

方法

BuildChannelFactory<TChannel>(BindingParameterCollection)

在客户端上生成通道工厂堆栈,此通道工厂堆栈创建具有指定类型的通道并满足绑定参数集合所指定的功能。Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by a collection of binding parameters.

(继承自 Binding)
BuildChannelFactory<TChannel>(Object[])

在客户端上生成通道工厂堆栈,该通道工厂堆栈创建具有指定类型的通道并满足对象数组所指定的功能。Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by an object array.

(继承自 Binding)
BuildChannelListener<TChannel>(BindingParameterCollection)

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足绑定参数集合所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified by a collection of binding parameters.

(继承自 Binding)
BuildChannelListener<TChannel>(Object[])

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, BindingParameterCollection)

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, Object[])

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection)

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[])

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
BuildChannelListener<TChannel>(Uri, String, Object[])

在服务上生成通道侦听器,该通道侦听器接受具有指定类型的通道并满足所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(继承自 Binding)
CanBuildChannelFactory<TChannel>(BindingParameterCollection)

返回一个值,该值指示当前绑定是否可以在客户端上生成满足指定绑定参数集合的通道工厂堆栈。Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the collection of binding parameters specified.

(继承自 Binding)
CanBuildChannelFactory<TChannel>(Object[])

返回一个值,该值指示当前绑定是否可以在客户端上生成满足对象数组所指定的需求的通道工厂堆栈。Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the requirements specified by an object array.

(继承自 Binding)
CanBuildChannelListener<TChannel>(BindingParameterCollection)

返回一个值,该值指示当前绑定是否可以在服务上生成满足指定绑定参数集合的通道侦听器堆栈。Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the collection of binding parameters specified.

(继承自 Binding)
CanBuildChannelListener<TChannel>(Object[])

返回一个值,该值指示当前绑定是否可以在服务上生成满足对象数组所指定的条件的通道侦听器堆栈。Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the criteria specified in an array of objects.

(继承自 Binding)
CreateBindingElements()

为绑定创建一个绑定元素集合。Creates a collection with the binding elements for the binding.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetProperty<T>(BindingParameterCollection)

从绑定堆栈的适当层返回所请求的类型化对象(如果存在)。Returns a typed object requested, if present, from the appropriate layer in the binding stack.

(继承自 Binding)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ShouldSerializeMaxConnections()

返回一个值,该值指示 MaxConnections 属性是否已更改,不再是默认值且应对其进行序列化。Returns a value that indicates whether the MaxConnections property has changed from its default value and should be serialized.

ShouldSerializeName()

返回是否应序列化绑定名称。Returns whether the name of the binding should be serialized.

(继承自 Binding)
ShouldSerializeNamespace()

返回是否应序列化绑定命名空间。Returns whether the namespace of the binding should be serialized.

(继承自 Binding)
ShouldSerializeReaderQuotas()

返回一个值,该值指示 ReaderQuotas 属性是否已更改,不再是默认值且应对其进行序列化。Returns a value that indicates whether the ReaderQuotas property has changed from its default value and should be serialized. WCF 使用此项进行 XAML 集成。This is used by WCF for XAML integration.

ShouldSerializeSecurity()

返回一个值,该值指示 Security 属性是否已更改,不再是默认值且应对其进行序列化。Returns a value that indicates whether the Security property has changed from its default value and should be serialized. WCF 使用此项进行 XAML 集成。This is used by WCF for XAML integration.

ShouldSerializeTransactionProtocol()

返回一个值,该值指示 TransactionProtocol 属性是否已更改,不再是默认值且应对其进行序列化。Returns a value that indicates whether the TransactionProtocol property has changed from its default value and should be serialized. WCF 使用此项进行 XAML 集成。This is used by WCF for XAML integration.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

IBindingRuntimePreferences.ReceiveSynchronously

获取一个值,该值指示是同步处理传入请求还是异步处理传入请求。Gets a value that indicates whether incoming requests are handled synchronously or asynchronously.

适用于