WellKnownClientTypeEntry 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
存有在用戶端登錄為伺服器啟動型別 (單一呼叫或單一物件) 之物件型別的值。
public ref class WellKnownClientTypeEntry : System::Runtime::Remoting::TypeEntry
public class WellKnownClientTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class WellKnownClientTypeEntry : System.Runtime.Remoting.TypeEntry
type WellKnownClientTypeEntry = class
inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type WellKnownClientTypeEntry = class
inherit TypeEntry
Public Class WellKnownClientTypeEntry
Inherits TypeEntry
- 繼承
- 屬性
範例
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownClientTypeEntry_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 with channel services.
ChannelServices::RegisterChannel( gcnew HttpChannel );
Console::WriteLine( " Start calling from Client One......." );
WellKnownClientTypeEntry^ myWellKnownClientTypeEntry = gcnew WellKnownClientTypeEntry( HelloServer::typeid,"http://localhost:8086/SayHello" );
myWellKnownClientTypeEntry->ApplicationUrl = "http://localhost:8086/SayHello";
RemotingConfiguration::RegisterWellKnownClientType( myWellKnownClientTypeEntry );
// Get the proxy object for the remote object.
HelloServer^ myHelloServerObject = gcnew HelloServer;
// Retrieve an array of object types registered on the
// client end as well-known types.
array<WellKnownClientTypeEntry^>^myWellKnownClientTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownClientTypes();
Console::WriteLine( "The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[ 0 ]->ApplicationUrl );
Console::WriteLine( "The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[ 0 ] );
// Make remote method calls.
for ( int i = 0; i < 5; i++ )
Console::WriteLine( myHelloServerObject->HelloMethod( " Client One" ) );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
public class MyClient
{
public static void Main()
{
// Create a 'HttpChannel' object and register with channel services.
ChannelServices.RegisterChannel(new HttpChannel());
Console.WriteLine(" Start calling from Client One.......");
WellKnownClientTypeEntry myWellKnownClientTypeEntry =
new WellKnownClientTypeEntry(typeof(HelloServer),
"http://localhost:8086/SayHello");
myWellKnownClientTypeEntry.ApplicationUrl="http://localhost:8086/SayHello";
RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry);
// Get the proxy object for the remote object.
HelloServer myHelloServerObject = new HelloServer();
// Retrieve an array of object types registered on the
// client end as well-known types.
WellKnownClientTypeEntry [] myWellKnownClientTypeEntryCollection =
RemotingConfiguration.GetRegisteredWellKnownClientTypes();
Console.WriteLine("The Application Url to activate the Remote Object :"
+myWellKnownClientTypeEntryCollection[0].ApplicationUrl);
Console.WriteLine("The 'WellKnownClientTypeEntry' object :"
+myWellKnownClientTypeEntryCollection[0].ToString());
// Make remote method calls.
for (int i = 0; i < 5; i++)
Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"));
}
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http
Public Class MyClient
Public Shared Sub Main()
' Create a 'HttpChannel' object and register with channel services.
ChannelServices.RegisterChannel(New HttpChannel())
Console.WriteLine(" Start calling from Client One.......")
Dim myWellKnownClientTypeEntry As New WellKnownClientTypeEntry(GetType(HelloServer), _
"http://localhost:8086/SayHello")
myWellKnownClientTypeEntry.ApplicationUrl = "http://localhost:8086/SayHello"
RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry)
' Get the proxy object for the remote object.
Dim myHelloServerObject As New HelloServer()
' Retrieve an array of object types registered on the
' client end as well-known types.
Dim myWellKnownClientTypeEntryCollection As WellKnownClientTypeEntry() = _
RemotingConfiguration.GetRegisteredWellKnownClientTypes()
Console.WriteLine("The Application Url to activate the Remote Object :" + _
myWellKnownClientTypeEntryCollection(0).ApplicationUrl)
Console.WriteLine("The 'WellKnownClientTypeEntry' object :" + _
myWellKnownClientTypeEntryCollection(0).ToString())
' Make remote method calls.
Dim i As Integer
For i = 0 To 4
Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"))
Next i
End Sub
End Class
備註
伺服器啟動的類型可以是單一呼叫或單一呼叫。 如果類別註冊為單一呼叫類型,每次從用戶端呼叫時都會建立新的實例。 單一物件的所有呼叫都會由該物件的一個實例處理,除非已經收集該物件。
任何知道已註冊伺服器啟動物件的 URI 的用戶端都可以藉由註冊慣 ChannelServices 用的通道,以及呼叫 new
或 Activator.GetObject來啟用物件,來取得此物件的 Proxy。 若要使用 new
啟用伺服器啟動的物件,您必須先使用 RegisterWellKnownClientType 方法在用戶端上註冊伺服器啟動的物件類型。 藉由呼叫 RegisterWellKnownClientType,您會將遠端基礎結構的位置提供給遠端物件,讓 new
關鍵詞能夠建立它。 另一方面, Activator.GetObject 如果您使用 方法來啟動伺服器啟動的物件,則必須提供物件的URL作為自變數,因此不需要在用戶端上事先註冊。
如需伺服器啟動物件和遠端物件啟用的詳細描述,請參閱 啟用遠程物件。
建構函式
WellKnownClientTypeEntry(String, String, String) |
使用指定的型別、組件名稱和物件 URL,初始化 WellKnownClientTypeEntry 類別的新執行個體。 |
WellKnownClientTypeEntry(Type, String) |
使用指定的型別和 URL,初始化 WellKnownClientTypeEntry 類別的新執行個體。 |
屬性
ApplicationUrl |
取得或設定要在其中啟動型別之應用程式的 URL。 |
AssemblyName |
取得設定為遠端啟動型別之物件型別的組件名稱。 (繼承來源 TypeEntry) |
ObjectType |
取得伺服器啟動用戶端型別的 Type。 |
ObjectUrl |
取得伺服器啟動用戶端物件的 URL。 |
TypeName |
取得設定為遠端啟動型別之物件型別的完整型別名稱。 (繼承來源 TypeEntry) |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回伺服器啟動用戶端型別的完整型別名稱、組件名稱和物件 URL 做為 String。 |