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

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.

 

Solution:

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)});

   }

 

References:

1.       http://support.microsoft.com/kb/2013194

2.       http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/a1203900-236a-40de-aabe-56ce2758f596

Tags: