Today I was debugging an issue where a service calls a client (duplex situation) which calls a different method on the server. It was always failing with an InvalidOperationException on the client despite my having placed ConcurrencyMode:=ConcurrencyMode.Reentrant on the client class... or so I thought.
I had placed that attribute in a ServiceBehavior attribute on the client class that implemented the callback interface. However, when I read the error message more thoroughly, I saw that it mentioned CallbackContract rather than ServiceContract. Changing the class's attribute to CallbackBehavior made everything work fine. (CallbackContract goes on the interface.)
Interestingly enough, it partially worked before - the channel opened fine and the server could call methods on the client. I guess WCF just ignores the settings in ServiceContract on callbacks. So, don't use the "service" attributes on callback/client types; use the attributes specifically designed for callbacks.
No comments:
Post a Comment