BindingElement.CanBuildChannelFactory Generic Method

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

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

public virtual bool CanBuildChannelFactory<TChannel> (
	BindingContext context
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 channel factory produces.



The BindingContext that provides context for the binding element.

Return Value

true if the IChannelFactory of type TChannel 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 factory for channels of type of TChannel can be build for the context provided before attempting to actually build the factory. Alternatively, just try to build the channel factory by calling BuildChannelFactory and catch the exception generated if it cannot be built.

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
BindingContext context = new BindingContext(binding, parameters);

bool bFlag = element.CanBuildChannelFactory<IRequestChannel>(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