Does OperationContextScope dispose communication channel as well?

747 views Asked by At

Does the OperationContextScope dispose the communication channel as well when it's disposed?

In the following example, I'm getting a "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state" exception when ServiceMethod executes the second time:

clientProxy = ...
public int ServiceMethod()
{
   using(OperationContextScope c = new OperationContextScope((IClientChannel)clientProxy))
   {
      //Add request header
      OperationContext.Current.OutgoingMessageHeaders.Add(...)
      clientProxy.method(...); //When this execute the second time, a fault state exception occur
   }

   //Add reply header
   OperationContext.Current.OutgoingMessageHeaders.Add(...)
   return 1;
}

Also, if it's important information, clientProxy.method() passes a callback.

1

There are 1 answers

0
user3186786 On

Apparently, the answer is no. I had a OneWay method that was throwing an uncaught exception. The exception was never shown in the service or the client so it was tricky to catch. Handling this solved the issue.