共用方式為


如何以程式設計方式設定通道

這個程式碼範例顯示如何以程式設計方式設定伺服器應用程式定義域的通道。在這種情況下,伺服器會指定遠端處理系統應使用 HttpChannel 物件進行傳輸,但使用 BinaryFormatter 物件進行序列化和還原序列化。

範例

Dim props = New Hashtable() As IDictionary
props("name") = "ChannelName1" 
Dim channel As New HttpChannel( _
   props, _
   Nothing, _
   New BinaryServerFormatterSinkProvider() _
)
ChannelServices.RegisterChannel(channel)
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
HttpChannel channel = new HttpChannel(
   props, 
   null, 
   new BinaryServerFormatterSinkProvider()
);
ChannelServices.RegisterChannel(channel);

請參閱

概念

通道和格式子組態屬性