Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 BuildChannelFactory(TChannel) Metho...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
BindingElement..::.BuildChannelFactory<(Of <(TChannel>)>) Method

Initializes a channel factory for producing channels of a specified type from the binding context.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Visual Basic (Declaration)
Public Overridable Function BuildChannelFactory(Of TChannel) ( _
    context As BindingContext _
) As IChannelFactory(Of TChannel)
Visual Basic (Usage)
Dim instance As BindingElement
Dim context As BindingContext
Dim returnValue As IChannelFactory(Of TChannel)

returnValue = instance.BuildChannelFactory(context)
C#
public virtual IChannelFactory<TChannel> BuildChannelFactory<TChannel>(
    BindingContext context
)
Visual C++
public:
generic<typename TChannel>
virtual IChannelFactory<TChannel>^ BuildChannelFactory(
    BindingContext^ context
)
JScript
JScript does not support generic types or methods.

Type Parameters

TChannel

The type of channel the factory builds.

Parameters

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

Return Value

Type: System.ServiceModel.Channels..::.IChannelFactory<(Of <(TChannel>)>)
The IChannelFactory<(Of <(TChannel>)>) of type TChannel initialized from the context.
ExceptionCondition
ArgumentNullException

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

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

IChannelFactory<IRequestChannel> factory = element.BuildChannelFactory<IRequestChannel>(context);
factory.Open();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
IRequestChannel channel = factory.CreateChannel(address);
channel.Open();
Message request = Message.CreateMessage(MessageVersion.Default, "hello");
Message reply = channel.Request(request);
Console.Out.WriteLine(reply.Headers.Action);
reply.Close();
channel.Close();
factory.Close();

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.

.NET Framework

Supported in: 3.5, 3.0

.NET Compact Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Missed a line in Examples      AchotStepanian   |   Edit   |   Show History
HttpTransportBindingElement 'element' has not been implemented
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker