ChannelFactory
// エンドポイント情報を構成ファイルに記述している場合、 // エンドポイント構成名をコンストラクタで指定する必要あり。 ChannelFactory<ISampleService> factory = new ChannelFactory<ISampleService>("test"); ISampleService channel = factory.CreateChannel(); channel.Greeting("Bob");
ClientBase
// 構成ファイルに記述してあるエンドポイントが1つだけの時は、 // コンストラクタでエンドポイント構成名を指定しなくてもいい。 SampleServiceClient client = new SampleServiceClient(); client.Greeting("Bob"); // 複数記述してある場合は例外が発生するので、 // 構成名を指定する必要がある。 // SampleServiceClient client = new SampleServiceClient("test"); // client.Greeting("Bob");
結論。WCF クライアントのエンドポイントを構成ファイルで指定するなら、構成名も指定しておく方が無難。