Bug? Content-Based Correlation in Windows Workflow Foundation
Thursday, August 22, 2013 at 10:33PM

This one caused me quite a bit of grief this week – maybe I can save someone else some pain. When configuring content-based correlation in the Workflow (4.0/4.5) designer, I think there’s a subtle bug in the dialog that allows you to choose the correlation key and XPath expression used to establish correlation on a Receive or SendReply activity.


It manifests itself when the workflow engine attempts to apply the correlation query at runtime:

A correlation query yielded an empty result set. Please ensure correlation queries for the endpoint are correctly configured.


It only occurs under the following conditions:


Under these conditions, the Add Correlation Initializers dialog sets the namespace of the property as being defined in the namespace of the derived class, not the base class.

Fortunately the fix is easy – you can manually edit the XAML to refer to the namespace of the base class instead, e.g:

<XPathMessageQuery x:Key="key1">
    <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/ClassLibrary2</x:String>
    <x:String x:Key="xgSc">http://tempuri.org/</x:String>
Update on Wednesday, December 25, 2013 at 11:26AM by Registered CommenterlessCode

Here is the sample solution. The fix is to change the value of Key xg0 to refer to ClassLibrary2 instead of ClassLibrary1 (which is what the designer wants to set it to).

Article originally appeared on lesscode.net (http://lesscode.net/).
See website for complete article licensing information.