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を登録してから、 または Activator.CreateInstanceを呼び出newしてオブジェクトをアクティブ化する必要があります。

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

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

こちらもご覧ください

適用対象

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を登録してから、 または Activator.CreateInstanceを呼び出newしてオブジェクトをアクティブ化する必要があります。

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

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

こちらもご覧ください

適用対象