System.ServiceModel 名前空間


.NET Framework クラス ライブラリ
ClientBase<(Of <(TChannel>)>) クラス

更新 : 2007 年 11 月

サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。

名前空間 :  System.ServiceModel
アセンブリ :  System.ServiceModel (System.ServiceModel.dll 内)
構文

Visual Basic (宣言)
Public MustInherit Class ClientBase(Of TChannel As Class) _
    Implements ICommunicationObject, IDisposable
Visual Basic (使用法)
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
J#
J# では、ジェネリック API は使用できますが、新規に宣言することはできません。
JScript
JScript では、ジェネリックな型またはメソッドは使用できません。

型パラメータ

TChannel

サービスに接続するために使用されるチャネル。

解説

ClientBase<(Of <(TChannel>)>) クラスを拡張して、サービスに接続するために使用できるカスタム WCF クライアント オブジェクトを作成します。通常、WCF クライアント基本クラスは、開発者ではなく、ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe) などのツールによって拡張されます。例については、「使用例」のセクションを参照してください。

ClientBase<(Of <(TChannel>)>) は、開発者がインターフェイスと System.ServiceModel..::.ChannelFactory<(Of <(TChannel>)>) クラスではなくオブジェクトの使用を希望する場合に、容易に使用できるクラスです。どのような場合でも、このクラスは、System.ServiceModel..::.ChannelFactory<(Of <(TChannel>)>) クラスと System.ServiceModel..::.IClientChannel インターフェイスのメソッドと機能をラップまたは公開します。

System.ServiceModel..::.ServiceHost クラスを使用しているときは、任意の呼び出しを行うとき、または Open を呼び出す前に、このクラスを作成して、エンドポイント、チャネル ファクトリ、またはセキュリティ情報を変更できます。詳細については、「WCF クライアントの概要」および「WCF クライアントを使用したサービスへのアクセス」を参照してください。

このクラスから派生するマネージ C++ ユーザーに対する特別な注意 :

  • クリーンアップ コードは、デストラクタではなく (On)(Begin)Close (または OnAbort のどちらか一方または両方) に置いてください。

  • デストラクタは使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。

  • 非参照メンバを使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。

  • ファイナライザを使用しないでください。使用する場合は、ビルド警告を抑制し、SuppressFinalize(Object) を呼び出し、ファイナライザ自体を (On)(Begin)Close (または OnAbort のどちらか一方または両方) から呼び出して、自動生成される IDisposable の動作をエミュレートする必要があります。


次のコード例は、ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe)ClientBase<(Of <(TChannel>)>) クラスを拡張して WCF クライアント クラスを作成する方法を示しています。

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>)>)
スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報

.NET Framework

サポート対象 : 3.5、3.0
参照

参照

タグ :


Page view tracker