次の方法で共有


RemotingConfiguration.RegisterActivatedClientType メソッド

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

オーバーロードの一覧

サーバーでアクティブにできる型として、クライアント エンドで提供される ActivatedClientTypeEntry に記録されているオブジェクト Type を登録します。

[Visual Basic] Overloads Public Shared Sub RegisterActivatedClientType(ActivatedClientTypeEntry)

[C#] public static void RegisterActivatedClientType(ActivatedClientTypeEntry);

[C++] public: static void RegisterActivatedClientType(ActivatedClientTypeEntry*);

[JScript] public static function RegisterActivatedClientType(ActivatedClientTypeEntry);

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

[Visual Basic] Overloads Public Shared Sub RegisterActivatedClientType(Type, String)

[C#] public static void RegisterActivatedClientType(Type, string);

[C++] public: static void RegisterActivatedClientType(Type*, String*);

[JScript] public static function RegisterActivatedClientType(Type, String);

使用例

[Visual Basic, C#, C++] サーバーでアクティブにできる型としてクライアント エンドでオブジェクト型を登録する例を次に示します。ここで示すクライアント コードに対応するサーバー コードについては、 RegisterActivatedServiceType メソッドのトピックの例を参照してください。

[Visual Basic, C#, C++] メモ   ここでは、RegisterActivatedClientType のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
Imports System
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")
      
      Dim service As New HelloServiceClass()
      
      If service Is Nothing Then
         Console.WriteLine("Could not locate server.")
         Return
      End If
      
      ' 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()

   End Sub 'Main

End Class 'ClientClass

[C#] 
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");

        HelloServiceClass service = new HelloServiceClass();

        if(service == null) {
            Console.WriteLine("Could not locate server.");
            return;
        }

        // 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();
    }
}

[C++] 
#using <mscorlib.dll>
#using <system.dll>
#using <system.runtime.remoting.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(new TcpChannel());

    RemotingConfiguration::RegisterActivatedClientType(__typeof(HelloServiceClass),
        S"tcp://localhost:8082");

    HelloServiceClass* service = new HelloServiceClass();

    if (service == 0) 
    {
        Console::WriteLine(S"Could not locate server.");
        return -1;
    }

    // Calls the remote method.
    Console::WriteLine();
    Console::WriteLine(S"Calling remote Object");
    Console::WriteLine(service->HelloMethod(S"Caveman"));
    Console::WriteLine(service->HelloMethod(S"Spaceman"));
    Console::WriteLine(service->HelloMethod(S"Client Man"));
    Console::WriteLine(S"Finished remote Object call");
    Console::WriteLine();

    return 0;
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

RemotingConfiguration クラス | RemotingConfiguration メンバ | System.Runtime.Remoting 名前空間