I have a service like this:
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract=typeof(IMyServiceCallback))]
public interface IMyService
{
[OperationContract]
bool CallService();
}
public interface IMyServiceCallback
{
[OperationContract(IsOneWay = true)]
void NotifyClient();
}
In the implementation of NotifyClient() I attempt to make a call to CallService(). This results in an InvalidOperationException:
Additional information: This operation would deadlock because the reply cannot be received until the current Message completes processing. If you want to allow out-of-order message processing, specify ConcurrencyMode of Reentrant or Multiple on CallbackBehaviorAttribute.
My service has ServiceBehavior set as follows:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession, ConcurrencyMode=ConcurrencyMode.Multiple, UseSynchronizationContext=false)]
and my callback has CallbackBehavior as:
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext=false)]
What could be causing this exception? I have also tried using ConcurrencyMode.Reentrant, but that doesn't help. I am able to get round the problem by invoking CallService() on a worker thread, but I would still like to know what is causing the exception.
Thanks.
Edit: added [OperationContract(IsOneWay = true)], but the problem remains.