ActivatedServiceTypeEntry 类

将在服务端注册的对象类型的值保存为可以应客户端请求激活的类型。

**命名空间:**System.Runtime.Remoting
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<ComVisibleAttribute(True)> _
Public Class ActivatedServiceTypeEntry
    Inherits TypeEntry
用法
Dim instance As ActivatedServiceTypeEntry
[ComVisibleAttribute(true)] 
public class ActivatedServiceTypeEntry : TypeEntry
[ComVisibleAttribute(true)] 
public ref class ActivatedServiceTypeEntry : public TypeEntry
/** @attribute ComVisibleAttribute(true) */ 
public class ActivatedServiceTypeEntry extends TypeEntry
ComVisibleAttribute(true) 
public class ActivatedServiceTypeEntry extends TypeEntry

备注

当前类由 RemotingConfiguration.RegisterActivatedServiceType 方法使用,而该方法是 RemotingConfiguration.RegisterActivatedClientType 方法的服务器端副本。RegisterActivatedServiceType 方法在服务器上用来允许客户端远程激活指定的对象类型。

若要在服务器上创建客户端激活的对象,则必须知道其 Type,而且必须使用 RegisterActivatedServiceType 方法在服务器端注册该对象。若要获取新的客户端激活对象的代理,则客户端必须首先通过 ChannelServices 注册信道,然后通过调用 newActivator.CreateInstance 来激活该对象。

若要激活具有 new 关键字的客户端激活对象类型,必须首先使用 RegisterActivatedClientType 方法在客户端注册该对象类型。通过调用 RegisterActivatedClientType 可为远程处理基础结构提供远程应用程序的位置,new 关键字试图在该处进行创建。另一方面,如果使用 CreateInstance 方法来创建客户端激活的对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此,没有必要预先在客户端注册。若要为 CreateInstance 方法提供要在其上创建该对象的服务器的 URL,必须将该 URL 封装到 UrlAttribute 类的实例中。

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

示例

Imports System
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 'Main
End Class 'MyClient
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();
   }
}
#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();
}
import System.*;
import System.Runtime.Remoting.*;
import System.Runtime.Remoting.Channels.*;
import System.Runtime.Remoting.Channels.Tcp.*;

public class MyClient
{
    public static void main(String[] args)
    {
        ChannelServices.RegisterChannel(new TcpChannel(8082));

        // Create an instance of 'ActivatedServiceTypeEntry' class
        // which holds the values for 'HelloServer' type.
        ActivatedServiceTypeEntry myActivatedServiceTypeEntry = 
            new ActivatedServiceTypeEntry(HelloServer.class.ToType());

        // 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: " 
            + ((ActivatedServiceTypeEntry)myActivatedServiceEntries.
            get_Item(0)).get_ObjectType());
        Console.WriteLine("Description: " 
            + myActivatedServiceEntries.get_Item(0).ToString());

        Console.WriteLine("Press enter to stop this process");
        Console.ReadLine();
    } //main
} //MyClient

继承层次结构

System.Object
   System.Runtime.Remoting.TypeEntry
    System.Runtime.Remoting.ActivatedServiceTypeEntry

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ActivatedServiceTypeEntry 成员
System.Runtime.Remoting 命名空间
RegisterActivatedServiceType

其他资源

客户端激活