Literal only supports value types and the immutable type System.String: Error

The following errors were encountered while processing the workflow tree:

'Literal<DataRow>': Literal only supports value types and the immutable type System.String.  The type System.Data.DataRow cannot be used as a literal.



If you happen to get the above or similar error stating that you cannot use value types as a literal, then here is what you can do to resolve it.

Here this code or code similar to this is what causes the above type of errors:

IDictionary<string, object> output;

foreach (DataRow row in dataTableList.Rows)


output = WorkflowInvoker.Invoke(new myWorkflowActivity() { arg1 = row });



To Resolve the error I had to re-write the above code as follows.  Notice the highlighted code, I had to rewrite to use lambda. That seems to solve the problem.  This solution is based on suggestion by Microsoft. Click Here


IDictionary<string, object> output;

foreach (DataRow rowPackge in dataTableList.Rows)


output = WorkflowInvoker.Invoke(new myWorkflowActivity () { arg1 = new InArgument<DataRow>((env) => row)});