0
votes

Is it possible to use dynamic objects (extending DynamicObject) in WF4 Activity that can be used in expressions?

I get the following error messages when running a unit test that invokes an activity that had a dynamic object as a parameter.

using DynamicObject as the argument type

System.Activities.InvalidWorkflowException : The following errors were encountered while processing the workflow tree: 'Literal': Literal only supports value types and the immutable type System.String. The type System.Dynamic.DynamicObject cannot be used as a literal. 'Legal': The private implementation of activity '1: Legal' has the following validation error: Compiler error(s) encountered processing expression "deal.Region = "EMEA"". 'Region' is not a member of 'System.Dynamic.DynamicObject'.

Using actual type as argument type

System.Activities.InvalidWorkflowException : The following errors were encountered while processing the workflow tree: 'Literal': Literal only supports value types and the immutable type System.String. The type WorkflowTest.DealValueHelper cannot be used as a literal. 'Legal': The private implementation of activity '1: Legal' has the following validation error: Compiler error(s) encountered processing expression "deal.Region = "EMEA"". 'Region' is not a member of 'WorkflowTest.DealValueHelper'.

1
Did Ron's post work for you? If so, please mark it as the answer for the community. Thanks! - Mike Perrenoud

1 Answers

1
votes

Yes, this absolutely works. I've created just such an object in Microsoft.Activities.Extensions.WorkflowArguments.

What you are encountering is likely an error when trying to assign directly to an InArgument of an activity. I wrote a blog post about this Passing arguments to Workflow Activities (again)