방법: 프로그래밍 방식으로 채널 구성
이 코드 예에서는 서버 응용 프로그램 도메인에 대한 채널을 프로그래밍 방식으로 구성하는 방법을 보여 줍니다. 이 경우 서버는 원격 시스템에서 데이터 전송에는 HttpChannel 개체를 사용하지만 serialization 및 deserialization에 대해서는 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);