摘要:WCF使用外部config筆記
- 改用System.ServiceModel.Configuration.ConfigurationChannelFactory<T>來產生Proxy
- 建立時傳入Configuration物件
- 可以利用Enterprise Library的ConfigurationSourceFactory來算簡化找尋外部config
var source = ConfigurationSourceFactory.Create();
var config = source.GetSection("system.serviceModel");
ConfigurationChannelFactory<IXXXXChannel> stockChannelFactory =
new ConfigurationChannelFactory<IXXXXChannel>(
regionId, config.CurrentConfiguration, null);
var client = stockChannelFactory.CreateChannel();
client.DoSomething();