WellKnownServiceTypeEntry 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
存有在服務端登錄為伺服器啟動型別物件 (單一呼叫或單一物件) 之物件型別的值。
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來啟用物件,來取得此物件的 Proxy。
請務必注意,註冊程式不會建立遠程物件本身。 只有在用戶端嘗試在物件上呼叫方法或從客戶端啟動物件時,才會發生這種情況。
如需伺服器啟動物件和遠端物件啟用的更詳細描述,請參閱 遠端物件的啟用。
建構函式
WellKnownServiceTypeEntry(String, String, String, WellKnownObjectMode) |
使用指定的型別名稱、組件名稱、物件 URI 和 WellKnownServiceTypeEntry,初始化 WellKnownObjectMode 類別的新執行個體。 |
WellKnownServiceTypeEntry(Type, String, WellKnownObjectMode) |
使用指定的 WellKnownServiceTypeEntry、物件 URI 和 Type,初始化 WellKnownObjectMode 類別的新執行個體。 |
屬性
AssemblyName |
取得設定為遠端啟動型別之物件型別的組件名稱。 (繼承來源 TypeEntry) |
ContextAttributes |
取得或設定伺服器啟動服務型別的內容屬性 (Attribute)。 |
Mode |
取得伺服器啟動服務型別的 WellKnownObjectMode。 |
ObjectType |
取得伺服器啟動服務型別的 Type。 |
ObjectUri |
取得已知服務型別的 URI。 |
TypeName |
取得設定為遠端啟動型別之物件型別的完整型別名稱。 (繼承來源 TypeEntry) |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回伺服器啟動型別的型別名稱、組件名稱、物件 URI 和 WellKnownObjectMode 做為 String。 |