Share via


ChannelServices.RegisterChannel 方法

定義

多載

RegisterChannel(IChannel)
已淘汰.

登錄具有通道服務的通道。 RegisterChannel(IChannel) 已經過時。 請改用 RegisterChannel(IChannel, Boolean)

RegisterChannel(IChannel, Boolean)

登錄具有通道服務的通道。

RegisterChannel(IChannel)

警告

Use System.Runtime.Remoting.ChannelServices.RegisterChannel(IChannel chnl, bool ensureSecurity) instead.

登錄具有通道服務的通道。 RegisterChannel(IChannel) 已經過時。 請改用 RegisterChannel(IChannel, Boolean)

public:
 static void RegisterChannel(System::Runtime::Remoting::Channels::IChannel ^ chnl);
public static void RegisterChannel (System.Runtime.Remoting.Channels.IChannel chnl);
[System.Obsolete("Use System.Runtime.Remoting.ChannelServices.RegisterChannel(IChannel chnl, bool ensureSecurity) instead.", false)]
public static void RegisterChannel (System.Runtime.Remoting.Channels.IChannel chnl);
static member RegisterChannel : System.Runtime.Remoting.Channels.IChannel -> unit
[<System.Obsolete("Use System.Runtime.Remoting.ChannelServices.RegisterChannel(IChannel chnl, bool ensureSecurity) instead.", false)>]
static member RegisterChannel : System.Runtime.Remoting.Channels.IChannel -> unit
Public Shared Sub RegisterChannel (chnl As IChannel)

參數

chnl
IChannel

要登錄的通道。

屬性

例外狀況

chnl 參數為 null

通道已經登錄。

至少有一個呼叫堆疊中較高的呼叫端,不具有設定遠端類型和通道的使用權限。

範例

HttpChannel^ channel = gcnew HttpChannel( 9000 );
ChannelServices::RegisterChannel( channel, false );
RemotingConfiguration::RegisterWellKnownServiceType( SampleNamespace::SampleService::typeid, "MySampleService/SampleService::soap", WellKnownObjectMode::Singleton );
Console::WriteLine( "** Press enter to end the server process. **" );
Console::ReadLine();
HttpChannel channel = new HttpChannel(9000);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType( typeof(SampleService),
"MySampleService/SampleService.soap", WellKnownObjectMode.Singleton);

Console.WriteLine("** Press enter to end the server process. **");
Console.ReadLine();
Dim channel As New HttpChannel(9000)
ChannelServices.RegisterChannel(channel)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(SampleService), "MySampleService/SampleService.soap", WellKnownObjectMode.Singleton)

Console.WriteLine("** Press enter to end the server process. **")
Console.ReadLine()

備註

方法會 RegisterChannel 從通道物件取用 IChannel 介面。 通道必須是唯一的 ChannelName ,否則通道必須是匿名的。 如果 IChannel.ChannelNamenull 設為 或 Empty ,則通道為匿名,方法是使用 name 組態屬性。

您無法在 中註冊兩個具有相同名稱的 AppDomain通道。 根據預設,的名稱 HttpChannel 是 「HTTP」 而名稱 TcpChannel 是 「tcp」。因此,如果您想要註冊兩個相同類型的通道,您必須透過組態屬性為其中一個通道指定不同的名稱。

如需通道組態屬性的詳細資訊,請參閱 HttpChannel<channel> Element (Template)

適用於

RegisterChannel(IChannel, Boolean)

登錄具有通道服務的通道。

public:
 static void RegisterChannel(System::Runtime::Remoting::Channels::IChannel ^ chnl, bool ensureSecurity);
public static void RegisterChannel (System.Runtime.Remoting.Channels.IChannel chnl, bool ensureSecurity);
static member RegisterChannel : System.Runtime.Remoting.Channels.IChannel * bool -> unit
Public Shared Sub RegisterChannel (chnl As IChannel, ensureSecurity As Boolean)

參數

chnl
IChannel

要登錄的通道。

ensureSecurity
Boolean

true 會確保啟用安全性,否則為 false。 將值設定為 false 不會影響 TCP 或 IPC 通道上的安全性設定。

例外狀況

chnl 參數為 null

通道已經登錄。

至少有一個呼叫堆疊中較高的呼叫端,不具有設定遠端類型和通道的使用權限。

HttpServerChannel 上並不支援。 如果您需要安全的 HTTP 通道,請裝載使用網際網路資訊服務 (IIS) 的服務。

備註

方法 RegisterChannel(IChannel, Boolean)IChannel 從通道物件接收 介面。 通道必須是唯一的 ChannelName ,否則通道必須是匿名的。 如果 IChannel.ChannelNamenull 設為 或 Empty ,則通道為匿名,方法是使用 name 組態屬性。

您無法在 中註冊兩個具有相同名稱的 AppDomain通道。 根據預設,的名稱 HttpChannel 為 「HTTP」 而的名稱 TcpChannel 為 「tcp」。 因此,如果您想要註冊兩個相同類型的通道,您必須透過組態屬性為其中一個通道指定不同的名稱。

如需通道組態屬性的詳細資訊,請參閱 通道和格式器 組態屬性和 <通道> 元素 (樣本)

ensureSecurity如果 參數設定true為 ,遠端系統會判斷通道是否實作 ISecurableChannel,如果是,則啟用加密和數字簽名。 如果通道未實 ISecurableChannel作 ,則會擲回例外狀況。

注意

將設定 ensureSecuritytrue 在所有平台上擲 RemotingException 回 通道的 HttpServerChannel 。 如果您想要使用安全的 HTTP 通道,您必須在 IIS 中裝載您的服務。

適用於