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

クライアント側でアクティブ化される型の構成設定。

例外

コールスタックの上位にある 1 つ以上の呼び出し元に、リモート処理の型とチャネルを構成するためのアクセス許可がありません。

注釈

サーバー上にクライアントでアクティブ化されたオブジェクトのインスタンスを作成するには、その Type インスタンスを認識している必要があり、 メソッドを使用 RegisterActivatedServiceType してサーバー側に登録する必要があります。 クライアントでアクティブ化されたオブジェクトの新しいインスタンスのプロキシを取得するには、クライアントが最初に にチャネル ChannelServices を登録してから、 を呼び出 newしてオブジェクトをアクティブ化する必要があります。

キーワード (keyword)を使用してクライアントでアクティブ化されたオブジェクトの種類をnewアクティブ化するには、 メソッドを使用して最初にクライアント側にオブジェクトの種類を登録する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。

例外

typeName パラメーターまたは URI パラメーターが null です。

コールスタックの上位にある 1 つ以上の呼び出し元に、リモート処理の型とチャネルを構成するためのアクセス許可がありません。

次のコード例は、サーバー上でアクティブ化できる型として、クライアント 側でのオブジェクト型の登録を示しています。 提示されたクライアント コードに対応するサーバー コードについては、 メソッドの例を 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してオブジェクトをアクティブ化する必要があります。

キーワード (keyword)を使用してクライアントでアクティブ化されたオブジェクトの種類をnewアクティブ化するには、 メソッドを使用して最初にクライアント側にオブジェクトの種類を登録するRegisterActivatedClientType必要があります。 メソッドを RegisterActivatedClientType 呼び出すと、リモート処理インフラストラクチャに、リモート アプリケーションの作成を試みる場所が new 提供されます。 一方、 メソッドを使用 Activator.CreateInstance してクライアントでアクティブ化されたオブジェクトの新しいインスタンスを作成する場合は、リモート アプリケーションの URL をパラメーターとして指定する必要があるため、クライアント側での事前登録は必要ありません。 オブジェクトを Activator.CreateInstance 作成するサーバーの URL を メソッドに指定するには、 クラスのインスタンスに URL をカプセル化する UrlAttribute 必要があります。

クライアントでアクティブ化されたオブジェクトの詳細については、「クライアントの アクティブ化」を参照してください。

こちらもご覧ください

適用対象