Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Add checks for Wcf client operation context #47

Merged
merged 3 commits into from
Aug 9, 2016

Conversation

tomasr
Copy link
Contributor

@tomasr tomasr commented Aug 9, 2016

Make the WcfOperationContext more robust with explicit checks to prevent creating a context on a WCF client-side OperationContext instance.

Also add a workaround for issue #45.

The fundamental issue here is that the WCF design around OperationContext is broken: You can stack contexts through the use of OperationContext.Current, but there is no way to navigate from the child context back to the parent.

The workaround uses CallContext to track the original OperationContext if the service code fails to dispose the OperationContextScope and we end up with OperationContext.Current returning the wrong value.

Not sure if using ThreadLocal<T> coupled with an AsyncLocal<T> here would be better than using CallContext in this case. Reluctant to have to mirror the jumps that WCF OperationContext.Current does.

Tomas Restrepo added 2 commits August 9, 2016 10:40
Implement checks to avoid creating a WcfOperationContext over a client-side OperationContext object. Store WcfOperationContext on the thread's CallContext as a backup.
@SergeyKanzhelev SergeyKanzhelev merged commit 1b7f16b into microsoft:master Aug 9, 2016
@tomasr tomasr deleted the WcfClientOperationContext branch August 9, 2016 23:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants