RemotingConfiguration.RegisterActivatedClientType 方法

定义

将客户端上的对象 Type 注册为可在服务器上激活的类型。

重载

RegisterActivatedClientType(ActivatedClientTypeEntry)

将在客户端提供的 Type 中记录的对象 ActivatedClientTypeEntry 注册为可在服务器上激活的类型。

RegisterActivatedClientType(Type, String)

通过使用给定的参数初始化 Type 类的新实例,将客户端上的对象 ActivatedClientTypeEntry 注册为可在服务器上激活的类型。

RegisterActivatedClientType(ActivatedClientTypeEntry)

将在客户端提供的 Type 中记录的对象 ActivatedClientTypeEntry 注册为可在服务器上激活的类型。

public:
 static void RegisterActivatedClientType(System::Runtime::Remoting::ActivatedClientTypeEntry ^ entry);
public static void RegisterActivatedClientType (System.Runtime.Remoting.ActivatedClientTypeEntry entry);
static member RegisterActivatedClientType : System.Runtime.Remoting.ActivatedClientTypeEntry -> unit
Public Shared Sub RegisterActivatedClientType (entry As ActivatedClientTypeEntry)

参数

entry
ActivatedClientTypeEntry

客户端激活类型的配置设置。

例外

在调用堆栈上部,至少有一个调用方没有配置远程处理类型和通道的权限。

注解

若要在服务器上创建客户端激活对象的实例,必须知道它 Type ,并且必须使用 方法在服务器端 RegisterActivatedServiceType 注册该对象。 若要获取客户端激活对象的新实例的代理,客户端必须先向 ChannelServices 注册通道,然后通过调用 new来激活该对象。

若要使用 new 关键字 (keyword) 激活客户端激活的对象类型,必须先使用 RegisterActivatedClientType 方法在客户端上注册对象类型。 RegisterActivatedClientType调用 方法会为远程处理基础结构提供尝试创建远程应用程序new的位置。 另一方面,如果使用 Activator.CreateInstance 方法创建客户端激活对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此无需在客户端上事先注册。 若要为 Activator.CreateInstance 方法提供要在其中创建 对象的服务器的 URL,必须将 URL 封装在 类的 UrlAttribute 实例中。

有关客户端激活对象的详细说明,请参阅 客户端激活

另请参阅

适用于

RegisterActivatedClientType(Type, String)

通过使用给定的参数初始化 Type 类的新实例,将客户端上的对象 ActivatedClientTypeEntry 注册为可在服务器上激活的类型。

public:
 static void RegisterActivatedClientType(Type ^ type, System::String ^ appUrl);
public static void RegisterActivatedClientType (Type type, string appUrl);
static member RegisterActivatedClientType : Type * string -> unit
Public Shared Sub RegisterActivatedClientType (type As Type, appUrl As String)

参数

type
Type

对象 Type

appUrl
String

在该处激活类型的应用程序的 URL。

例外

typeNameURI 参数为 null

在调用堆栈上部,至少有一个调用方没有配置远程处理类型和通道的权限。

示例

下面的代码示例演示了在客户端上将对象类型注册为可在服务器上激活的类型。 有关与呈现的客户端代码对应的服务器代码,请参阅 方法的示例 RegisterActivatedServiceType

#using <system.dll>
#using <system.runtime.remoting.dll>
#using "service.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

int main()
{
   ChannelServices::RegisterChannel( gcnew TcpChannel );
   RemotingConfiguration::RegisterActivatedClientType( HelloServiceClass::typeid, "tcp://localhost:8082" );
   try
   {
      HelloServiceClass ^ service = gcnew HelloServiceClass;

      // Calls the remote method.
      Console::WriteLine();
      Console::WriteLine( "Calling remote Object" );
      Console::WriteLine( service->HelloMethod( "Caveman" ) );
      Console::WriteLine( service->HelloMethod( "Spaceman" ) );
      Console::WriteLine( service->HelloMethod( "Client Man" ) );
      Console::WriteLine( "Finished remote Object call" );
    }
    catch (Exception ex)
    {
        Console::WriteLine("An exception occurred: " + ex.Message);
    }
   Console::WriteLine();
   return 0;
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class ClientClass {

    public static void Main() {

        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                   "tcp://localhost:8082");

        try
        {
            HelloServiceClass service = new HelloServiceClass();

           // Calls the remote method.
           Console.WriteLine();
           Console.WriteLine("Calling remote object");
           Console.WriteLine(service.HelloMethod("Caveman"));
           Console.WriteLine(service.HelloMethod("Spaceman"));
           Console.WriteLine(service.HelloMethod("Client Man"));
           Console.WriteLine("Finished remote object call");
           Console.WriteLine();
        }
    catch (Exception ex)
    {
       Console.WriteLine("An exception occurred: " + ex.Message);
        }
    }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp


Public Class ClientClass
   
   Public Shared Sub Main()
      
      ChannelServices.RegisterChannel(New TcpChannel())
      
      RemotingConfiguration.RegisterActivatedClientType(GetType(HelloServiceClass), "tcp://localhost:8082")
      
      Try
          Dim service As New HelloServiceClass()
      
       
          ' Calls the remote method.
          Console.WriteLine()
          Console.WriteLine("Calling remote object")
          Console.WriteLine(service.HelloMethod("Caveman"))
          Console.WriteLine(service.HelloMethod("Spaceman"))
          Console.WriteLine(service.HelloMethod("Client Man"))
          Console.WriteLine("Finished remote object call")
      Catch ex as Exception
          Console.WriteLine("An exception occurred: " + ex.Message)
      End Try

      Console.WriteLine()

   End Sub

End Class

注解

若要在服务器上创建客户端激活对象的实例,必须知道它 Type ,并且必须使用 方法在服务器端 RegisterActivatedServiceType 注册该对象。 若要获取客户端激活对象的新实例的代理,客户端必须先向 ChannelServices 注册通道,然后通过调用 new来激活该对象。

若要使用 new 关键字 (keyword) 激活客户端激活的对象类型,必须先使用 RegisterActivatedClientType 方法在客户端上注册对象类型。 RegisterActivatedClientType调用 方法会为远程处理基础结构提供尝试创建远程应用程序new的位置。 另一方面,如果使用 Activator.CreateInstance 方法创建客户端激活对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此无需在客户端上事先注册。 若要为 Activator.CreateInstance 方法提供要在其中创建 对象的服务器的 URL,必须将 URL 封装在 类的 UrlAttribute 实例中。

有关客户端激活对象的详细说明,请参阅 客户端激活

另请参阅

适用于