WellKnownServiceTypeEntry 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将在服务端注册的对象类型的值保存为服务器激活类型对象(单个调用或 singleton)。
public ref class WellKnownServiceTypeEntry : System::Runtime::Remoting::TypeEntry
public class WellKnownServiceTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class WellKnownServiceTypeEntry : System.Runtime.Remoting.TypeEntry
type WellKnownServiceTypeEntry = class
inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type WellKnownServiceTypeEntry = class
inherit TypeEntry
Public Class WellKnownServiceTypeEntry
Inherits TypeEntry
- 继承
- 属性
示例
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownServiceTypeEntry_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 it with the
// channel services.
ChannelServices::RegisterChannel( gcnew HttpChannel( 8086 ) );
// Record the 'HelloServer' type as 'Singleton' well-known type.
WellKnownServiceTypeEntry^ myWellKnownServiceTypeEntry = gcnew WellKnownServiceTypeEntry( HelloServer::typeid,"SayHello",WellKnownObjectMode::Singleton );
// Register the remote object as well-known type.
RemotingConfiguration::RegisterWellKnownServiceType( myWellKnownServiceTypeEntry );
// Retrieve object types registered on the service end
// as well-known types.
array<WellKnownServiceTypeEntry^>^myWellKnownServiceTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownServiceTypes();
Console::WriteLine( "The 'WellKnownObjectMode' of the remote object : {0}", myWellKnownServiceTypeEntryCollection[ 0 ]->Mode );
Console::WriteLine( "The 'WellKnownServiceTypeEntry' object: {0}", myWellKnownServiceTypeEntryCollection[ 0 ] );
Console::WriteLine( "Started the Server, Hit <enter> to exit..." );
Console::ReadLine();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
public class MyServer
{
public static void Main()
{
// Create a 'HttpChannel' object and register it with the
// channel services.
ChannelServices.RegisterChannel(new HttpChannel(8086));
// Record the 'HelloServer' type as 'Singleton' well-known type.
WellKnownServiceTypeEntry myWellKnownServiceTypeEntry=
new WellKnownServiceTypeEntry(typeof(HelloServer),
"SayHello",
WellKnownObjectMode.Singleton);
// Register the remote object as well-known type.
RemotingConfiguration.RegisterWellKnownServiceType(
myWellKnownServiceTypeEntry);
// Retrieve object types registered on the service end
// as well-known types.
WellKnownServiceTypeEntry [] myWellKnownServiceTypeEntryCollection =
RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
Console.WriteLine("The 'WellKnownObjectMode' of the remote object : "
+myWellKnownServiceTypeEntryCollection[0].Mode);
Console.WriteLine("The 'WellKnownServiceTypeEntry' object: "+
myWellKnownServiceTypeEntryCollection[0].ToString());
Console.WriteLine("Started the Server, Hit <enter> to exit...");
Console.ReadLine();
}
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http
Public Class MyServer
Public Shared Sub Main()
' Create a 'HttpChannel' object and register it with the
' channel services.
ChannelServices.RegisterChannel(New HttpChannel(8086))
' Record the 'HelloServer' type as 'Singleton' well-known type.
Dim myWellKnownServiceTypeEntry As New WellKnownServiceTypeEntry(GetType(HelloServer), _
"SayHello", WellKnownObjectMode.Singleton)
' Register the remote object as well-known type.
RemotingConfiguration.RegisterWellKnownServiceType(myWellKnownServiceTypeEntry)
' Retrieve object types registered on the service end
' as well-known types.
Dim myWellKnownServiceTypeEntryCollection As WellKnownServiceTypeEntry() = _
RemotingConfiguration.GetRegisteredWellKnownServiceTypes()
Console.WriteLine("The 'WellKnownObjectMode' of the remote object : " + _
myWellKnownServiceTypeEntryCollection(0).Mode.ToString())
Console.WriteLine("The 'WellKnownServiceTypeEntry' object: " + _
myWellKnownServiceTypeEntryCollection(0).ToString())
Console.WriteLine("Started the Server, Hit <enter> to exit...")
Console.ReadLine()
End Sub
End Class
注解
服务器激活的对象类型可以是单个调用或单一实例。 如果对象类型是单个调用,则每次来自客户端的调用时,都会创建它的新实例。 对单一实例对象的所有调用都由该对象的一个实例处理。
任何知道此对象的 URI 的客户端都可以通过注册首选 ChannelServices 通道并通过调用 new
或 Activator.GetObject来激活对象来获取此对象的代理。
请务必注意,远程对象本身不是由注册过程创建的。 仅当客户端尝试对对象调用方法或从客户端激活对象时,才会发生这种情况。
有关服务器激活的对象和远程对象激活的更详细说明,请参阅 远程对象的激活。
构造函数
WellKnownServiceTypeEntry(String, String, String, WellKnownObjectMode) |
使用给定的类型名称、程序集名称、对象 URI 和 WellKnownServiceTypeEntry 初始化 WellKnownObjectMode 类的新实例。 |
WellKnownServiceTypeEntry(Type, String, WellKnownObjectMode) |
使用给定的 WellKnownServiceTypeEntry、对象 URI 和 Type 初始化 WellKnownObjectMode 类的新实例。 |
属性
AssemblyName |
获取配置为远程激活类型的对象类型的程序集名称。 (继承自 TypeEntry) |
ContextAttributes |
获取或设置服务器激活服务类型的上下文特性。 |
Mode |
获取服务器激活服务类型的 WellKnownObjectMode。 |
ObjectType |
获取服务器激活服务类型的 Type。 |
ObjectUri |
获取已知服务类型的 URI。 |
TypeName |
获取配置为远程激活类型的对象类型的完整类型名。 (继承自 TypeEntry) |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
以 WellKnownObjectMode 的形式返回服务器激活类型的类型名称、程序集名称、对象 URI 和 String。 |