WF Custom Actions - Location Matters!
Firstly, many thanks to Kavita Kamani for helping me figure this one out.
As you may or may not know, Windows Workflow Foundation contains a lightweight, forward-chaining rules engine (by lightweight, I mean to say non-Rete). In WF rules, a rule is defined by a condition, a collection of "then" actions, and a collection of "else" actions. One of the really cool things about the way that the rules engine is structured is that it allows you to create your own custom actions. Why would you want to do this? Quite simply, because within a custom action, you have access to both the validation context and the execution context. Therefore, custom actions in effect provide a means for extending the rules language.
There's only one gotcha to look out for when creating custom actions (there might be more, but here's the one that bit me). If you create the action within the same project that contains the workflow using the action, you will get the following error when you try to call it from within the rules editor.
After beating my head against a wall for a while trying to figure out the problem, I realized that if I moved my custom action to another project and referenced it from the project that contained my workflow, everything worked just fine. Kavita confirmed this behavior and explained that the WF Rule Editor uses CLR types rather than design-time types. As such, as far as the rules editor is concerned, my custom action doesn't exist so long as it is in the same project.
I am currently the Editor-in-Chief for MSDN Magazine. I joined Microsoft in 2006 as a product planner with the certification team at Microsoft Learning. Prior to that, I spent my career as a developer and later as an architect. My main technology passions include pretty much anything on language theory, agile development, and service-oriented architecture.