WCF Callback Channel gets disposed prematurely

.net-3.5callbackwcf

My application is using the net.tcp WCF service with a callback channel. For some reason I'm not able to send callbacks on event. Here's what I'm doing (all code server-side):

On initialization:

OperationContext Context { get; protected set; }
...
Context = OperationContext.Current;

On event:

var callback = Context.GetCallbackChannel<IServiceCallbackContract>();
callback.SomeMethod();

This fails on SomeMethod() with following exception: {"Cannot access a disposed object.\r\nObject name: 'System.ServiceModel.Channels.ServiceChannel'."}

Apparently, something disposes callback channel, even though client still able to talk to server using direct (non-callback) channel. This is pretty weird. Which object am I supposed to hold on to in order to issue a callback? Is there a certain thread this must be running in?

Best Answer

Configure Tracing and see what exception is faulting your channel.