次の方法で共有


WellKnownClientTypeEntry クラス

サーバー側でアクティブ化される型 (単一の呼び出しまたはシングルトン) としてクライアントに登録されたオブジェクト型の値を保持します。

この型のすべてのメンバの一覧については、WellKnownClientTypeEntry メンバ を参照してください。

System.Object
   System.Runtime.Remoting.TypeEntry
      System.Runtime.Remoting.WellKnownClientTypeEntry

Public Class WellKnownClientTypeEntry
   Inherits TypeEntry
[C#]
public class WellKnownClientTypeEntry : TypeEntry
[C++]
public __gc class WellKnownClientTypeEntry : public TypeEntry
[JScript]
public class WellKnownClientTypeEntry extends TypeEntry

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

サーバー側でアクティブ化される型には、単一の呼び出しまたはシングルトンがあります。クラスが単一呼び出し型として登録されている場合は、クライアントからの呼び出しが到達するたびに、新しいインスタンスが作成されます。シングルトン オブジェクトのすべての呼び出しは、オブジェクトが収集されていない限り、そのオブジェクトの 1 つのインスタンスによって処理されます。

登録されたサーバー側でアクティブ化されるオブジェクトの URI を知っているすべてのクライアントは、 ChannelServices で優先するチャネルを登録し、 new または Activator.GetObject を呼び出してそのオブジェクトをアクティブにすることにより、このオブジェクトに対するプロキシを取得できます。 new でサーバー側でアクティブ化されるオブジェクトをアクティブにするには、初めに RegisterWellKnownClientType メソッドを使用して、そのサーバー側でアクティブ化されるオブジェクトの型をクライアント側で登録しておく必要があります。 RegisterWellKnownClientType を呼び出すと、 new キーワードに作成を許可するリモート オブジェクトの場所がリモート処理インフラストラクチャに通知されます。一方、 Activator.GetObject メソッドを使用して、サーバー側でアクティブ化されるオブジェクトをアクティブにする場合は、そのオブジェクトの URL を引数として指定する必要があります。このため、クライアント側での事前の登録は必要ありません。

サーバー側でアクティブ化されるオブジェクトとリモート オブジェクト アクティベーションの詳細については、「 アクティベーション 」を参照してください。

使用例

 
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http

Public Class MyClient
   
   Public Shared Sub Main()
      ' Create a 'HttpChannel' object and  register with channel services.
      ChannelServices.RegisterChannel(New HttpChannel())
      Console.WriteLine(" Start calling from Client One.......")
      Dim myWellKnownClientTypeEntry As New WellKnownClientTypeEntry(GetType(HelloServer), _ 
                                                  "https://localhost:8086/SayHello")
      myWellKnownClientTypeEntry.ApplicationUrl = "https://localhost:8086/SayHello"
      RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry)
      ' Get the proxy object for the remote object.
      Dim myHelloServerObject As New HelloServer()
      ' Retrieve an array of object types registered on the 
      ' client end as well-known types.
      Dim myWellKnownClientTypeEntryCollection As WellKnownClientTypeEntry() = _ 
                                       RemotingConfiguration.GetRegisteredWellKnownClientTypes()
      Console.WriteLine("The Application Url to activate the Remote Object :" + _ 
                                           myWellKnownClientTypeEntryCollection(0).ApplicationUrl)
      Console.WriteLine("The 'WellKnownClientTypeEntry' object :" + _ 
                                              myWellKnownClientTypeEntryCollection(0).ToString())
      ' Make remote method calls.
      Dim i As Integer
      For i = 0 To 4
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"))
      Next i
   End Sub 'Main
End Class 'MyClient 

[C#] 
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class MyClient 
{
   public static void Main()
   {
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices.RegisterChannel(new HttpChannel());
   Console.WriteLine(" Start calling from Client One.......");
   WellKnownClientTypeEntry myWellKnownClientTypeEntry = 
                  new WellKnownClientTypeEntry(typeof(HelloServer),
                                  "https://localhost:8086/SayHello");
   myWellKnownClientTypeEntry.ApplicationUrl="https://localhost:8086/SayHello";
   RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry);
   // Get the proxy object for the remote object.
   HelloServer myHelloServerObject = new HelloServer();
   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   WellKnownClientTypeEntry [] myWellKnownClientTypeEntryCollection = 
          RemotingConfiguration.GetRegisteredWellKnownClientTypes();
   Console.WriteLine("The Application Url to activate the Remote Object :"
        +myWellKnownClientTypeEntryCollection[0].ApplicationUrl);
   Console.WriteLine("The 'WellKnownClientTypeEntry' object :"
            +myWellKnownClientTypeEntryCollection[0].ToString());
   // Make remote method calls.
   for (int i = 0; i < 5; i++)
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"));
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownClientTypeEntry_Share.dll>
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Http;

int main()
{
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices::RegisterChannel(new HttpChannel());
   Console::WriteLine(S" Start calling from Client One.......");
   WellKnownClientTypeEntry* myWellKnownClientTypeEntry = 
      new WellKnownClientTypeEntry(__typeof(HelloServer),
      S"https://localhost:8086/SayHello");
   myWellKnownClientTypeEntry->ApplicationUrl=S"https://localhost:8086/SayHello";
   RemotingConfiguration::RegisterWellKnownClientType(myWellKnownClientTypeEntry);
   // Get the proxy object for the remote object.
   HelloServer* myHelloServerObject = new HelloServer();
   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   WellKnownClientTypeEntry* myWellKnownClientTypeEntryCollection[] = 
      RemotingConfiguration::GetRegisteredWellKnownClientTypes();
   Console::WriteLine(S"The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[0]->ApplicationUrl);
   Console::WriteLine(S"The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[0]);
   // Make remote method calls.
   for (int i = 0; i < 5; i++)
      Console::WriteLine(myHelloServerObject->HelloMethod(S" Client One"));
}

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

必要条件

名前空間: System.Runtime.Remoting

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: Mscorlib (Mscorlib.dll 内)

参照

WellKnownClientTypeEntry メンバ | System.Runtime.Remoting 名前空間 | RegisterWellKnownClientType | サーバー アクティベーション