■ はじめに
* CommunicationObject.State プロパティで、状態を知ることが可能。
参考文献
http://msdn.microsoft.com/ja-jp/library/ms789041.aspxhttp://msdn.microsoft.com/ja-jp/library/system.servicemodel.communicationstate(v=vs.85).aspx
■ Faulted
* 回復不能なエラーや障害が発生し、使用できない状態になっていることを示す
対処
* Fault 状態にあるオブジェクトは、Abort メソッドを使用して閉じる必要がある
例外のハンドリング
ChannelFactory<ISampleService> sampleServiceFactory = null; ISampleService client = sampleServiceFactory.CreateChannel(); sampleServiceFactory.Faulted+= new EventHandler(ProxyServiceFactoryOnFaulted); private void ProxyServiceFactoryOnFaulted(object sender, EventArgs e) { (sender as ISampleService ).Abort(); if (sender is ISampleService) { sender = this.sampleServiceFactory.CreateChannel(); } }
参考文献
http://setus.blogspot.jp/2009/06/how-to-reconnect-to-wcf-service-after.htmlhttp://nahidulkibria.blogspot.jp/2008/05/knowing-when-wcf-service-in-fault-state.html
http://blog.tallan.com/2009/05/06/recover-from-a-wcf-service-fault/