.NET Framework Class Library
BindingElement..::.BuildChannelListener<(Of <(TChannel>)>) Method

Initializes a channel listener to accept channels of a specified type from the binding context.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Syntax

Visual Basic (Declaration)
Public Overridable Function BuildChannelListener(Of TChannel As {Class, IChannel}) ( _
    context As BindingContext _
) As IChannelListener(Of TChannel)
Visual Basic (Usage)
Dim instance As BindingElement
Dim context As BindingContext
Dim returnValue As IChannelListener(Of TChannel)

returnValue = instance.BuildChannelListener(context)
C#
public virtual IChannelListener<TChannel> BuildChannelListener<TChannel>(
    BindingContext context
)
where TChannel : class, IChannel
Visual C++
public:
generic<typename TChannel>
where TChannel : ref class, IChannel
virtual IChannelListener<TChannel>^ BuildChannelListener(
    BindingContext^ context
)
JScript
JScript does not support generic types or methods.

Type Parameters

TChannel

The type of channel the listener is built to accept.

Parameters

context
Type: System.ServiceModel.Channels..::.BindingContext
The BindingContext that provides context for the binding element.

Return Value

Type: System.ServiceModel.Channels..::.IChannelListener<(Of <(TChannel>)>)
The IChannelListener<(Of <(TChannel>)>) of type IChannel initialized from the context.
Exceptions

ExceptionCondition
ArgumentNullException

context is nullNothingnullptra null reference (Nothing in Visual Basic).

Examples

C#
CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
Uri baseAddress = new Uri("http://localhost:8000/ChannelApp");
String relAddress = "http://localhost:8000/ChannelApp/service";
BindingContext context = new BindingContext(binding, parameters, baseAddress, relAddress, ListenUriMode.Explicit);

IChannelListener<IReplyChannel> listener = element.BuildChannelListener<IReplyChannel>(context);
listener.Open();
IReplyChannel channel = listener.AcceptChannel();
channel.Open();
RequestContext request = channel.ReceiveRequest();
Message msg = request.RequestMessage;
Console.WriteLine("Message Received");
Console.WriteLine("Message Action: {0}", msg.Headers.Action);

if (msg.Headers.Action == "hello")
{
    Message reply = Message.CreateMessage(MessageVersion.Default, "wcf");
    request.Reply(reply);
}

msg.Close();
channel.Close();
listener.Close();
.NET Framework Security

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0

.NET Compact Framework

Supported in: 3.5
See Also

Reference

Tags :


Page view tracker