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 注册该对象。 若要获取新的客户端激活对象的代理,客户端必须先向 ChannelServices 注册通道,然后通过调用 newActivator.CreateInstance来激活该对象。

若要使用 new 关键字 (keyword) 激活客户端激活的对象类型,必须先使用 RegisterActivatedClientType 方法在客户端上注册对象类型。 通过调用 RegisterActivatedClientType ,你为远程处理基础结构提供了尝试创建远程应用程序 new 的位置。 另一方面,如果使用 CreateInstance 方法创建客户端激活对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此无需事先在客户端上注册。 若要为 CreateInstance 方法提供要在其中创建对象的服务器的 URL,必须将 URL 封装在 类的 UrlAttribute 实例中。

有关客户端激活的对象和远程对象激活的详细说明,请参阅 远程对象的激活

构造函数

ActivatedServiceTypeEntry(String, String)

用给定的类型名称和程序集名称初始化 ActivatedServiceTypeEntry 类的新实例。

ActivatedServiceTypeEntry(Type)

用给定的 ActivatedServiceTypeEntry 初始化 Type 类的新实例。

属性

AssemblyName

获取配置为远程激活类型的对象类型的程序集名称。

(继承自 TypeEntry)
ContextAttributes

获取或设置客户端激活服务类型的上下文特性。

ObjectType

获取客户端激活服务类型的 Type

TypeName

获取配置为远程激活类型的对象类型的完整类型名。

(继承自 TypeEntry)

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

String 的形式返回客户端激活服务类型的类型名称和程序集名称。

适用于

另请参阅