Hi,
How can I keep my WCF Service Client Connected with WinForm even if a Faulted State appened ?
Thanks.
Hi,
How can I keep my WCF Service Client Connected with WinForm even if a Faulted State appened ?
Thanks.
As far as I know, a faulted state is usually terminal to a WCF proxy. So no, I don't think so.
Answer myself :)
You might subscribe to InnerChannel Events
svc.InnerChannel.Closed += InnerChannel_Error;
svc.InnerChannel.Closing += InnerChannel_Error;
svc.InnerChannel.Faulted += InnerChannel_Error;
Then Handle Exceptions and Recreate the Service Proxy
private void InnerChannel_Error(object sender, EventArgs e)
{
var svc = _entrepotService as EntrepotServiceProxy;
try
{
if (svc != null)
{
if (svc.State != CommunicationState.Faulted)
{
svc.Close();
}
else
{
svc.Abort();
}
}
}
catch (CommunicationException)
{
if (svc != null) svc.Abort();
}
catch (TimeoutException)
{
if (svc != null) svc.Abort();
}
catch
{
if (svc != null) svc.Abort();
throw;
}
_entrepotService = new EntrepotServiceProxy();
}