次の方法で共有


RemotingConfiguration.RegisterActivatedClientType メソッド

定義

クライアント 側で Type オブジェクトを、サーバー上でアクティブ化できる型として登録します。

オーバーロード

名前 説明
RegisterActivatedClientType(ActivatedClientTypeEntry)

クライアント 側で指定されたActivatedClientTypeEntryに記録Typeオブジェクトを、サーバー上でアクティブ化できる型として登録します。

RegisterActivatedClientType(Type, String)

指定されたパラメーターを使用して、ActivatedClientTypeEntry クラスの新しいインスタンスを初期化して、クライアント 側でTypeオブジェクトをサーバー上でアクティブ化できる型として登録します。

RegisterActivatedClientType(ActivatedClientTypeEntry)

クライアント 側で指定されたActivatedClientTypeEntryに記録Typeオブジェクトを、サーバー上でアクティブ化できる型として登録します。

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を呼び出してオブジェクトをアクティブ化する必要があります。

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

こちらもご覧ください

適用対象

RegisterActivatedClientType(Type, String)

指定されたパラメーターを使用して、ActivatedClientTypeEntry クラスの新しいインスタンスを初期化して、クライアント 側でTypeオブジェクトをサーバー上でアクティブ化できる型として登録します。

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。

例外

typeまたはappUrlパラメーターが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を呼び出してオブジェクトをアクティブ化する必要があります。

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

こちらもご覧ください

適用対象