RemotingConfiguration.RegisterActivatedServiceType メソッド

定義

サービス エンドで Type オブジェクトを、クライアントからの要求時にアクティブ化できるオブジェクトとして登録します。

オーバーロード

名前 説明
RegisterActivatedServiceType(ActivatedServiceTypeEntry)

サービス エンドで指定された ActivatedServiceTypeEntry に記録されたオブジェクト型を、クライアントからの要求時にアクティブ化できるオブジェクト型として登録します。

RegisterActivatedServiceType(Type)

クライアントからの要求時にアクティブ化できる型として、サービス エンドで指定されたオブジェクト型を登録します。

RegisterActivatedServiceType(ActivatedServiceTypeEntry)

サービス エンドで指定された ActivatedServiceTypeEntry に記録されたオブジェクト型を、クライアントからの要求時にアクティブ化できるオブジェクト型として登録します。

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

パラメーター

entry
ActivatedServiceTypeEntry

クライアントでアクティブ化された種類の構成設定。

例外

呼び出し履歴の上位の呼び出し元の少なくとも 1 つに、リモート処理の種類とチャネルを構成するアクセス許可がありません。

注釈

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

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

こちらもご覧ください

適用対象

RegisterActivatedServiceType(Type)

クライアントからの要求時にアクティブ化できる型として、サービス エンドで指定されたオブジェクト型を登録します。

public:
 static void RegisterActivatedServiceType(Type ^ type);
public static void RegisterActivatedServiceType(Type type);
static member RegisterActivatedServiceType : Type -> unit
Public Shared Sub RegisterActivatedServiceType (type As Type)

パラメーター

type
Type

登録するオブジェクトの Type

例外

呼び出し履歴の上位の呼び出し元の少なくとも 1 つに、リモート処理の種類とチャネルを構成するアクセス許可がありません。

次のコード例は、クライアントによってアクティブ化できる型としてサーバー上のオブジェクト型を登録する方法を示しています。 提示されたサーバー コードに対応するクライアント コードについては、 RegisterActivatedClientType メソッドの例を参照してください。

#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( 8082 ) );
   RemotingConfiguration::RegisterActivatedServiceType( HelloServiceClass::typeid );
   Console::WriteLine( "Press enter to stop this process." );
   Console::ReadLine();
   return 0;
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class ServerClass {

    public static void Main()  {

        ChannelServices.RegisterChannel(new TcpChannel(8082));

        RemotingConfiguration.RegisterActivatedServiceType(typeof(HelloServiceClass));

        Console.WriteLine("Press enter to stop this process.");
        Console.ReadLine();
    }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp


Public Class ServerClass
      
   Public Shared Sub Main()
      
      ChannelServices.RegisterChannel(New TcpChannel(8082))     
      RemotingConfiguration.RegisterActivatedServiceType(GetType(HelloServiceClass))
      
      Console.WriteLine("Press enter to stop this process.")
      Console.ReadLine()

   End Sub

End Class

次のコード例は、上記のサンプル コードに登録されているサービス オブジェクトを示しています。

#using <system.dll>

using namespace System;

public ref class HelloServiceClass: public MarshalByRefObject
{
private:
   static int n_instance;

public:
   HelloServiceClass()
   {
      n_instance++;
      Console::WriteLine(  "{0} has been created.  Instance # = {1}", this->GetType()->Name, n_instance );
   }

   ~HelloServiceClass()
   {
      Console::WriteLine( "Destroyed instance {0} of HelloServiceClass.", n_instance );
      n_instance--;
   }

   String^ HelloMethod( String^ name )
   {
      // Reports that the method was called.
      Console::WriteLine();
      Console::WriteLine( "Called HelloMethod on instance {0} with the '{1}' parameter.", n_instance, name );

      // Calculates and returns the result to the client.
      return String::Format( "Hi there {0}", name );
   }
};
using System;

public class HelloServiceClass : MarshalByRefObject {

    static int n_instance;

    public HelloServiceClass() {
        n_instance++;
        Console.WriteLine(this.GetType().Name + " has been created.  Instance # = {0}", n_instance);
    }

    ~HelloServiceClass() {
        Console.WriteLine("Destroyed instance {0} of HelloServiceClass.", n_instance);
        n_instance --;
    }

    public String HelloMethod(String name) {

        // Reports that the method was called.
        Console.WriteLine();
        Console.WriteLine("Called HelloMethod on instance {0} with the '{1}' parameter.",
                             n_instance, name);

        // Calculates and returns the result to the client.
        return "Hi there " + name + ".";
    }
}
Public Class HelloServiceClass
   Inherits MarshalByRefObject
   
   Private Shared n_instance As Integer

      
   Public Sub New()
      n_instance += 1
      Console.WriteLine(Me.GetType().Name + " has been created.  Instance # = {0}", n_instance)
   End Sub
      
   
   Protected Overrides Sub Finalize()
      Console.WriteLine("Destroyed instance {0} of HelloServiceClass.", n_instance)
      n_instance -= 1
      MyBase.Finalize()
   End Sub
   
   
   
   Public Function HelloMethod(name As [String]) As [String]
      
      ' Reports that the method was called.
      Console.WriteLine()
      Console.WriteLine("Called HelloMethod on instance {0} with the '{1}' parameter.", n_instance, name)
      
      ' Calculates and returns the result to the client.
      Return "Hi there " + name + "."

   End Function 'HelloMethod

End Class

注釈

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

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

こちらもご覧ください

適用対象