It depends on what you mean by cancellation. Client code has called a method and expects a result or exception.
What you can do is to avoid calling the original method in your handler, effectively stopping the pipeline, but you need to do something to complete the method call.
To bypass the rest of the pipeline that includes the original method, you need to create a new return method using the CreateMethodReturn method in the IMethodInvocation interface to return successfully or using the CreateExceptionMethodReturn method to throw an exception. See http://msdn.microsoft.com/en-us/library/ee650526(v=pandp.20) for more details.
For example, instead of executing
return getNext()(input, getNext);
you could do
return input.CreateMethodReturn(null, input.Arguments)
to return null.
For a general purpose handler, you need to analyze the intercepted method signature to figure out what needs to be returned.
source share