0

My client is using one WCF service which is throwing an exception (EXCEPTION: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state). All subsequent calls throwing an same exception.

I read on internet that client need to close()/Abort() channel, this will solve the problem. is it completely right?

Also I am using customer serviceChannel factory provided by service developers. When I create channel it does not show the close and abort methods. So how do I get these close and abort methods when I create custom service channel instance on client side?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
sudhirk
  • 423
  • 1
  • 5
  • 12
  • possible duplicate of [How to make sure you don't get WCF Faulted state exception?](http://stackoverflow.com/questions/530731/how-to-make-sure-you-dont-get-wcf-faulted-state-exception) – Jeroen Sep 20 '12 at 12:51
  • It won't fix your problem directly - you cannot reuse a faulted channel (you will have to create a new one after disposing the old one). – slugster Sep 20 '12 at 12:51

1 Answers1

0

Assuming that you have a proxy instance that implements the IClientChannel interface, here is a way (hopefully the right way) to use it.

IClientChannel clientChannel = (IClientChannel)proxy;
bool success = false;

try
{
    // do something with the proxy
    clientChannel.Close();
    success = true;
}
finally
{
    if (!success)
    {
        clientChannel.Abort();
    }
}

You may also want to check this. You can wrap your operations using a shared class or function.

Community
  • 1
  • 1
Yiğit Yener
  • 5,796
  • 1
  • 23
  • 26
  • ok. I was wondering ,doing this alone on clinet side should solve the problem or some coding also neees to be done at WCF side? – sudhirk Sep 24 '12 at 07:12