Export (0) Print
Expand All

BindingElement.CanBuildChannelListener Generic Method

Returns a value that indicates whether the binding element can build a listener for a specific type of channel.

Namespace: System.ServiceModel.Channels
Assembly: System.ServiceModel (in system.servicemodel.dll)

public virtual bool CanBuildChannelListener<TChannel> (
	BindingContext context
) where TChannel : IChannel
J# supports the use of generic types and methods, but not the declaration of new ones.
JScript does not support generic types and methods.
Not applicable.

Type Parameters


The type of channel the listener accepts.



The BindingContext that provides context for the binding element.

Return Value

true if the IChannelListener of type IChannel can be built by the binding element; otherwise, false.

Exception typeCondition


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

Use this method if you want to check that the channel listener for channels of type of TChannel can be build for the context provided before attempting to actually build the listener. Alternatively, just try to build the channel listener by calling BuildChannelListener and catch the exception generated if it cannot be built.

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);

bool bFlag = element.CanBuildChannelListener<IReplyChannel>(context);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2015 Microsoft