RemotingConfiguration.RegisterWellKnownClientType メソッド

定義

既知の型 (単一の呼び出しまたはシングルトン) として、クライアント エンドでオブジェクト Type を登録します。

オーバーロード

RegisterWellKnownClientType(WellKnownClientTypeEntry)

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

RegisterWellKnownClientType(Type, String)

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

RegisterWellKnownClientType(WellKnownClientTypeEntry)

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

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

パラメーター

entry
WellKnownClientTypeEntry

既知の型の構成設定。

例外

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

注釈

登録済みの既知のオブジェクトの URI を認識するすべてのクライアントは、 に希望ChannelServicesするチャネルを登録し、 または Activator.GetObjectを呼び出newしてオブジェクトをアクティブ化することで、オブジェクトのプロキシを取得できます。 で既知のオブジェクト newをアクティブ化するには、 メソッドを使用して、まず既知のオブジェクト型をクライアントに登録する RegisterWellKnownClientType 必要があります。 メソッドをRegisterWellKnownClientType呼び出すと、リモート処理インフラストラクチャにリモート オブジェクトの場所が提供されます。これにより、キーワード (keyword)がリモート オブジェクトを作成できるようになりますnew。 一方、 メソッドを使用 Activator.GetObject して既知のオブジェクトをアクティブ化する場合は、オブジェクトの URL を引数として指定する必要があるため、クライアント側での事前登録は必要ありません。

既知のオブジェクトの詳細については、「 サーバーのアクティブ化」を参照してください。

こちらもご覧ください

適用対象

RegisterWellKnownClientType(Type, String)

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

public:
 static void RegisterWellKnownClientType(Type ^ type, System::String ^ objectUrl);
public static void RegisterWellKnownClientType (Type type, string objectUrl);
static member RegisterWellKnownClientType : Type * string -> unit
Public Shared Sub RegisterWellKnownClientType (type As Type, objectUrl As String)

パラメーター

type
Type

オブジェクト Type

objectUrl
String

既知のクライアント オブジェクトの URL。

例外

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

次のコード例は、既知の型として、クライアント 側でのオブジェクト型の登録を示しています。 提示されたクライアント コードに対応するサーバー コードについては、 メソッドの例を RegisterWellKnownServiceType 参照してください。

#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::Tcp;
using namespace System::Runtime::Remoting::Channels;
int main()
{
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;

public class ClientClass {

    public static void Main() {
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Channels


Public Class ClientClass
   
   
   Public Shared Sub Main()
ChannelServices::RegisterChannel( gcnew TcpChannel );
RemotingConfiguration::RegisterWellKnownClientType( HelloService::typeid,
                                                    "tcp://localhost:8082/HelloServiceApplication/MyUri" );
HelloService ^ service = gcnew HelloService;
ChannelServices.RegisterChannel(new TcpChannel());

RemotingConfiguration.RegisterWellKnownClientType(
                                                   typeof(HelloService),
                                                   "tcp://localhost:8082/HelloServiceApplication/MyUri"
                                                 );

HelloService service = new HelloService();
ChannelServices.RegisterChannel(New TcpChannel())

RemotingConfiguration.RegisterWellKnownClientType(GetType(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri")

Dim service As New HelloService()
   if ( service == nullptr )
   {
      Console::WriteLine( "Could not locate server." );
      return  -1;
   }

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

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

      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

End Class

注釈

登録済みの既知のオブジェクトの URI を認識するすべてのクライアントは、 に希望ChannelServicesするチャネルを登録し、 または Activator.GetObjectを呼び出newしてオブジェクトをアクティブ化することで、オブジェクトのプロキシを取得できます。 で既知のオブジェクト newをアクティブ化するには、 メソッドを使用して、まず既知のオブジェクト型をクライアントに登録する RegisterWellKnownClientType 必要があります。 メソッドをRegisterWellKnownClientType呼び出すと、リモート処理インフラストラクチャにリモート オブジェクトの場所が提供されます。これにより、キーワード (keyword)がリモート オブジェクトを作成できるようになりますnew。 一方、 メソッドを使用 Activator.GetObject して既知のオブジェクトをアクティブ化する場合は、オブジェクトの URL を引数として指定する必要があるため、クライアント側での事前登録は必要ありません。

既知のオブジェクトの詳細については、「 サーバーのアクティブ化」を参照してください。

こちらもご覧ください

適用対象