A good summary of all the extensibility points: https://blogs.msdn.microsoft.com/carlosfigueira/2011/03/14/wcf-extensibility/
Use IOperationInvoker
if you need to do "runtime-y" things, such as replacing the current SynchronizationContext (perhaps with one that restores OperationContext after an await
...).
But! You can only apply an IOperationInvoker
from an IOperationBehavior
, not from a IServiceBehavior
. If you try to assign an operation invoker from a service behavior, WCF will eventually just overwrite it. If you want to apply an IOperationInvoker
to every operation in a contract, you can write an IServiceBehavior
which applies the IOperationBehavior
to every operation.
You can have an attribute which can apply to a whole service, or to a single operation: