共用方式為


HOW TO:以程式設計方式設定通道

這個程式碼範例顯示如何以程式設計方式為伺服器應用程式定義域設定通道。在此情況下,伺服器會指定遠端系統應該使用 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);

請參閱

概念

通道和格式器組態屬性

Footer image

Copyright © 2007 by Microsoft Corporation. All rights reserved.