Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5

  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
ClientBase<(Of <(TChannel>)>) Class

Provides the base implementation used to create Windows Communication Foundation (WCF) client objects that can call services.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Visual Basic (Declaration)
Public MustInherit Class ClientBase(Of TChannel As Class) _
    Implements ICommunicationObject, IDisposable
Visual Basic (Usage)
Dim instance As ClientBase(Of TChannel)
C#
public abstract class ClientBase<TChannel> : ICommunicationObject, 
    IDisposable
where TChannel : class
Visual C++
generic<typename TChannel>
where TChannel : ref class
public ref class ClientBase abstract : ICommunicationObject, 
    IDisposable
JScript
JScript does not support generic types or methods.

Type Parameters

TChannel

The channel to be used to connect to the service.

Extend the ClientBase<(Of <(TChannel>)>) class to create a custom WCF client object that can be used to connect to a service. Typically, the WCF client base class is extended by a tool such as the ServiceModel Metadata Utility Tool (Svcutil.exe) on your behalf. For an example, see the Example section.

The ClientBase<(Of <(TChannel>)>) class can be used quickly and easily by developers who prefer objects to the use of the interfaces and the System.ServiceModel..::.ChannelFactory<(Of <(TChannel>)>) class. In all cases this class wraps or exposes the methods and functionality of the System.ServiceModel..::.ChannelFactory<(Of <(TChannel>)>) class and the System.ServiceModel..::.IClientChannel interface.

As when using the System.ServiceModel..::.ServiceHost class, you can create the class and modify the endpoint, channel factory, or security information prior to making any calls or calling Open. For more information, see WCF Client Overview and Accessing Services Using a WCF Client.

Special note for Managed C++ users deriving from this class:

  • Put your clean-up code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • Avoid destructors: they cause the compiler to auto-generate IDisposable.

  • Avoid non-reference members: they can cause the compiler to auto-generate IDisposable.

  • Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize(Object) and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated IDisposable behavior.

The following code example shows how the ServiceModel Metadata Utility Tool (Svcutil.exe) extends the ClientBase<(Of <(TChannel>)>) class to create a WCF client class.

C#
public partial class SampleServiceClient : System.ServiceModel.ClientBase<ISampleService>, ISampleService
{

    public SampleServiceClient()
    {
    }

    public SampleServiceClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }

    public SampleServiceClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public SampleServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }

    public string SampleMethod(string msg)
    {
        return base.Channel.SampleMethod(msg);
    }
}

System..::.Object
  System.ServiceModel..::.ClientBase<(Of <(TChannel>)>)
    System.ServiceModel..::.DuplexClientBase<(Of <(TChannel>)>)
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker