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 关键字激活客户端激活的对象类型,必须先使用 RegisterActivatedClientType 该方法在客户端上注册对象类型。 通过调用 RegisterActivatedClientType ,可以向远程基础结构提供远程应用程序的位置,以便 new 尝试创建远程应用程序。 另一方面, CreateInstance 如果使用该方法创建客户端激活对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此不需要在客户端上预先注册。 若要向方法提供 CreateInstance 要在其中创建对象的服务器的 URL,必须在类的 UrlAttribute 实例中封装该 URL。

构造函数

名称 说明
ActivatedServiceTypeEntry(String, String)

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

ActivatedServiceTypeEntry(Type)

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

属性

名称 说明
AssemblyName

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

(继承自 TypeEntry)
ContextAttributes

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

ObjectType

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

TypeName

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

(继承自 TypeEntry)

方法

名称 说明
Equals(Object)

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

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

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

适用于

另请参阅