Share via


ActivatedServiceTypeEntry 類別

定義

存有物件型別的值,此物件型別在服務端登錄為可依要求從用戶端啟動的型別。

public ref class ActivatedServiceTypeEntry : System::Runtime::Remoting::TypeEntry
public class ActivatedServiceTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class ActivatedServiceTypeEntry : System.Runtime.Remoting.TypeEntry
type ActivatedServiceTypeEntry = class
    inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type ActivatedServiceTypeEntry = class
    inherit TypeEntry
Public Class ActivatedServiceTypeEntry
Inherits TypeEntry
繼承
ActivatedServiceTypeEntry
屬性

範例

#using <System.Runtime.Remoting.dll>
#using <ActivatedServiceTypeEntry_ObjectType_Share.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
void main()
{
   ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) );
   
   // Create an instance of 'ActivatedServiceTypeEntry' class
   // which holds the values for 'HelloServer' type.
   ActivatedServiceTypeEntry^ myActivatedServiceTypeEntry =
      gcnew ActivatedServiceTypeEntry( HelloServer::typeid );
   
   // Register an object Type on the service end so that 
   // it can be activated on request from a client.
   RemotingConfiguration::RegisterActivatedServiceType(
      myActivatedServiceTypeEntry );
   
   // Get the registered activated service types.
   array<ActivatedServiceTypeEntry^>^ activatedServiceEntries =
      RemotingConfiguration::GetRegisteredActivatedServiceTypes();
   Console::WriteLine( "Information of first registered activated" +
     " service type :" );
   Console::WriteLine( "Object type: {0}",
      activatedServiceEntries[ 0 ]->ObjectType->ToString() );
   Console::WriteLine( "Description: {0}",
      activatedServiceEntries[ 0 ]->ToString() );

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

public class MyClient
{
   public static void Main()
   {
      ChannelServices.RegisterChannel(new TcpChannel(8082));
      // Create an instance of 'ActivatedServiceTypeEntry' class
      // which holds the values for 'HelloServer' type.
      ActivatedServiceTypeEntry myActivatedServiceTypeEntry =
                   new ActivatedServiceTypeEntry(typeof(HelloServer));
      // Register an object Type on the service end so that
      // it can be activated on request from a client.
      RemotingConfiguration.RegisterActivatedServiceType(
                                         myActivatedServiceTypeEntry);
      // Get the registered activated service types .
      ActivatedServiceTypeEntry[] myActivatedServiceEntries =
          RemotingConfiguration.GetRegisteredActivatedServiceTypes();
      Console.WriteLine("Information of first registered activated "
                             +" service type :");
      Console.WriteLine("Object type: "
                       +myActivatedServiceEntries[0].ObjectType);
      Console.WriteLine("Description: "
                           +myActivatedServiceEntries[0].ToString());
      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 MyClient
   
   Public Shared Sub Main()
      ChannelServices.RegisterChannel(New TcpChannel(8082))
      ' Create an instance of 'ActivatedServiceTypeEntry' class
      ' which holds the values for 'HelloServer' type.
      Dim myActivatedServiceTypeEntry As New ActivatedServiceTypeEntry(GetType(HelloServer))
      ' Register an object Type on the service end so that 
      ' it can be activated on request from a client.
      RemotingConfiguration.RegisterActivatedServiceType(myActivatedServiceTypeEntry)
      ' Get the registered activated service types .
      Dim myActivatedServiceEntries As ActivatedServiceTypeEntry() = RemotingConfiguration. _
                                                         GetRegisteredActivatedServiceTypes()
      Console.WriteLine("Information of first registered activated " + " service type :")
      Console.WriteLine("Object type: " + myActivatedServiceEntries(0).ObjectType.ToString())
      Console.WriteLine("Description: " + myActivatedServiceEntries(0).ToString())
      Console.WriteLine("Press enter to stop this process")
      Console.ReadLine()
   End Sub
End Class

備註

方法會 RemotingConfiguration.RegisterActivatedServiceType 使用目前的類別,這是方法的 RemotingConfiguration.RegisterActivatedClientType 伺服器端對應專案。 方法 RegisterActivatedServiceType 用於伺服器上,以允許指定物件類型的用戶端進行遠端啟用。

若要在伺服器上建立客戶端啟動的物件,您必須知道其 Type,而且必須使用 方法在伺服器端 RegisterActivatedServiceType 註冊它。 若要取得新用戶端啟動物件的 Proxy,客戶端必須先向 註冊通道 ChannelServices ,然後再呼叫 newActivator.CreateInstance來啟動物件。

若要使用 new 關鍵字啟動用戶端啟動的物件類型,您必須先使用 RegisterActivatedClientType 方法在用戶端上註冊物件類型。 呼叫 RegisterActivatedClientType 時,您會將遠端基礎結構的位置提供給遠端應用程式,以 new 嘗試建立遠端應用程式。 另一方面, CreateInstance 如果您使用 方法來建立用戶端啟動物件的新實例,則必須提供遠端應用程式的 URL 做為參數,因此不需要在用戶端上事先註冊。 若要提供 CreateInstance 方法以及您要在其中建立物件的伺服器URL,您必須將URL封裝在類別的 UrlAttribute 實例中。

如需客戶端啟動物件和遠端物件啟用的詳細描述,請參閱 啟用遠程物件

建構函式

ActivatedServiceTypeEntry(String, String)

使用指定的型別名稱和組件名稱,初始化 ActivatedServiceTypeEntry 類別的新執行個體。

ActivatedServiceTypeEntry(Type)

使用指定的 ActivatedServiceTypeEntry,初始化 Type 類別的新執行個體。

屬性

AssemblyName

取得設定為遠端啟動型別之物件型別的組件名稱。

(繼承來源 TypeEntry)
ContextAttributes

取得或設定用戶端啟動服務型別的內容屬性 (Attribute)。

ObjectType

取得用戶端啟動服務型別的 Type

TypeName

取得設定為遠端啟動型別之物件型別的完整型別名稱。

(繼承來源 TypeEntry)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回用戶端啟動服務型別的型別和組件名稱為 String

適用於

另請參閱