早上看到了博客园老大dudu的文章,不要在using语句中调用WCF服务,以及回复中的一个不错的解决办法
public partial class CnblogsWcfClient :IDisposable
{
void IDisposable.Dispose()
{
try { this.Close(); }
catch (CommunicationException e)
{
this.Abort();
}
catch (TimeoutException e)
{
this.Abort();
}
catch (Exception e)
{
this.Abort(); throw;
}
}
}
调用时
using (var client = new WcfWrapper<ServiceClient>(_service))
{
var callresult = client.WcfClient.Service(message);
}