语言

IpcClientChannel 类

定义

为使用 IPC 协议传输消息的远程调用实现客户端通道。

public ref class IpcClientChannel : System::Runtime::Remoting::Channels::IChannelSender, System::Runtime::Remoting::Channels::ISecurableChannel
public class IpcClientChannel : System.Runtime.Remoting.Channels.IChannelSender, System.Runtime.Remoting.Channels.ISecurableChannel
type IpcClientChannel = class
    interface IChannelSender
    interface IChannel
    interface ISecurableChannel
Public 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。

注解

Important

使用不受信任的数据调用此类中的方法存在安全风险。 仅在确保数据受信任的情况下,再从该类调用方法。 有关详细信息,请参阅验证所有输入。

通道由框架远程处理基础结构用来传输远程呼叫.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)

适用于