This project is read-only.

InstanceContext inside a WCF Behavior Assertion

Topics: Technical Questions
Mar 1, 2010 at 3:56 AM
Edited Mar 1, 2010 at 3:58 AM

Hi, I am trying to use InstanceContext Extensions to store custom data (i.e. transaction id) inside a WCF Behavior Assertion in MSE.

I have associated the assertion to a policy in MSE set as an endpoint.

The custom data is stored when my the endpoint is called. But the instance context is not recycled after the endpoint call is completed (i.e. instance context not reset, resulting in transaction id same as before)

I have verified that my wcf service's service behavior has InstanceContextMode set to PerCall.


Do you have any ideas why the instance context does not recycle after the client endpoint call completes?



Mar 1, 2010 at 4:48 AM

Also, what scope does the policy behavior run inside MSE?

Am curious because when debugging and inspecting my service class, it appears that OperationContext.Current.InstanceContext does not contain the custom data added within the WCF Behavior assertion in MSE.



Mar 1, 2010 at 5:50 PM

The MSE manages the InstanceContext of each virtual endpoint as a singleton which is why you are experiencing no recycling in your extension.  The Broker functionality in the MSE is coupled with the InstanceContext of each virtual endpoint.

For your example I'd suggest using an OperationContext extension rather than InstanceContext extension.