IpcClientChannel 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为远程调用实现使用 IPC 协议传输消息的客户端信道。
public ref class IpcClientChannel : System::Runtime::Remoting::Channels::IChannelSender, System::Runtime::Remoting::Channels::ISecurableChannelpublic class IpcClientChannel : System.Runtime.Remoting.Channels.IChannelSender, System.Runtime.Remoting.Channels.ISecurableChanneltype IpcClientChannel = class
    interface IChannelSender
    interface IChannel
    interface ISecurableChannelPublic Class IpcClientChannel
Implements IChannelSender, ISecurableChannel- 继承
- 
				IpcClientChannel
- 实现
示例
下面的代码示例演示如何使用 IpcClientChannel 类。
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <Counter.dll>
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Ipc;
public ref class Client
{
public:
   void ClientTest()
   {
      IpcClientChannel^ clientChannel = gcnew IpcClientChannel;
      ChannelServices::RegisterChannel( clientChannel );
      RemotingConfiguration::RegisterWellKnownClientType( Counter::typeid, L"ipc://remote/counter" );
      Counter^ counter = gcnew Counter;
      Console::WriteLine( L"This is call number {0}.", counter->Count );
   }
};
int main()
{
   Client^ c = gcnew Client;
   c->ClientTest();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
public class Client
{
    public static void Main ()
    {
        IpcClientChannel clientChannel = new IpcClientChannel();
        ChannelServices.RegisterChannel(clientChannel);
        RemotingConfiguration.RegisterWellKnownClientType( typeof(Counter) , "ipc://remote/counter" );
        Counter counter = new Counter();
        Console.WriteLine("This is call number {0}.", counter.Count);
    }
}
上述代码使用以下远程对象。
using namespace System;
public ref class Counter: public MarshalByRefObject
{
private:
   int count;
public:
   Counter()
   {
      count = 0;
   }
   property int Count 
   {
      int get()
      {
         return (count)++;
      }
   }
};
using System;
public class Counter : MarshalByRefObject {
  private int count = 0;
  public int Count { get {
    return(count++);
  } }
}
有关远程公开此对象的服务器的示例,请参阅 IpcServerChannel。
注解
重要
使用不受信任的数据调用此类中的方法存在安全风险。 仅使用受信任的数据调用此类中的方法。 有关详细信息,请参阅 验证所有输入。
the.NET 框架远程处理基础结构使用通道来传输远程呼叫。 当客户端调用远程对象时,调用将序列化为由客户端通道发送并由服务器通道接收的消息。 收到消息后,将对其进行反序列化和处理。 任何返回的值都由服务器通道传输,并由客户端通道接收。
类 IpcClientChannel 使用 Windows 进程间通信 (IPC) 系统在同一台计算机上的应用程序域之间传输消息。 在同一计算机上的应用程序域之间进行通信时,IPC 通道比 TCP 或 HTTP 通道快得多。
若要在客户端执行其他消息处理,可以指定 接口的实现, IClientChannelSinkProvider 通过该接口传递对象处理 IpcClientChannel 的所有消息。
默认情况下, IpcClientChannel 类使用二进制格式化程序来序列化所有消息。
IpcClientChannel对象具有关联的配置属性,可以在运行时通过调用静态RemotingConfiguration.Configure方法) (配置文件中设置这些属性,或通过将集合传递到IDictionaryIpcClientChannel构造函数) 以编程方式 (。 有关这些配置属性的列表,请参阅构造函数的文档 IpcClientChannel 。
构造函数
| IpcClientChannel() | 初始化 IpcServerChannel 类的新实例。 | 
| IpcClientChannel(IDictionary, IClientChannelSinkProvider) | 使用指定的配置属性和接收器初始化 IpcClientChannel 类的新实例。 | 
| IpcClientChannel(String, IClientChannelSinkProvider) | 使用指定的名称和接收器初始化 IpcClientChannel 类的新实例。 | 
属性
| ChannelName | 获取当前信道的名称。 | 
| ChannelPriority | 获取当前信道的优先级。 | 
| IsSecured | 获取或设置一个布尔值,该值指示当前信道是否安全。 | 
方法
| CreateMessageSink(String, Object, String) | 返回将消息传送到指定 URL 或信道数据对象的信道消息接收器。 | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| Parse(String, String) | 从指定 URL 提取信道 URI 和远程已知对象 URI。 | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |