SanjaySutar
asked on
WCF InvalidOperationException in service
Hi,
My WCF service is throwing exception as follows:
Service Code is as follows :
WCF Consumer UI class
Implementing CallBack on client side
[CallbackBehavior(Concurre ncyMode = ConcurrencyMode.Single)]
public class WebMxAccess : IWebMxAccessServerServiceC allback
{
}
I am getting above mentioned error when i am calling Register operation contract of service.
Any help would be appreciated.
My WCF service is throwing exception as follows:
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.
Service Code is as follows :
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class CalculatorService : IWebMxAccessServerService
{
public int Register(string tag)
{
int tagHandle = 0;
try
{
tagHandle = wmxServer.Advise(param1,param2);
return tagHandle;
}
catch (Exception ex)
{
EventLog.WriteEntry("WCF Service", ex.Message + Environment.NewLine + ex.StackTrace);
throw;
}
}
}
[ServiceContract(Namespace = "", SessionMode = SessionMode.Required,
CallbackContract = typeof(IWebMxAccessServerServiceCallback))]
public interface IWebMxAccessServerService
{
[OperationContract]
int Register(string tag);
}
public interface IWebMxAccessServerServiceCallback
{
[OperationContract(IsOneWay = true)]
void ReceiveMxData(TagUpdatedEventArgs tagDetails);
}
WCF Consumer UI class
Implementing CallBack on client side
[CallbackBehavior(Concurre
public class WebMxAccess : IWebMxAccessServerServiceC
{
}
I am getting above mentioned error when i am calling Register operation contract of service.
Any help would be appreciated.
ASKER
Hi Darren, I have added the attribute, but now started getting different error.
Please find below the stack trace :
Please find below the stack trace :
Message: The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout.
Source: mscorlib
Stack Trace:
Server stack trace:
at System.ServiceModel.Channels.TransmissionStrategy.WaitQueueAdder.Wait(TimeSpan timeout)
at System.ServiceModel.Channels.TransmissionStrategy.InternalAdd(Message message, Boolean isLast, TimeSpan timeout, Object state, MessageAttemptInfo& attemptInfo)
at System.ServiceModel.Channels.ReliableOutputConnection.InternalAddMessage(Message message, TimeSpan timeout, Object state, Boolean isLast)
at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.DuplexChannel.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Darren, thanks for the example.
I have fixed the problem of Timout.
Along with the attribute mentioned by you earlier, I have added UseSynchronizationContext = false and it started working.
Thanks again.
I have fixed the problem of Timout.
Along with the attribute mentioned by you earlier, I have added UseSynchronizationContext = false and it started working.
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, UseSynchronizationContext = false)]
Thanks again.
On the Service add ConcurrencyMode=Concurrenc
Hope this helps,
Darren