2012-08-10 19 views
0

是否可以在WF4活動中使用可用於表達式中的動態對象(擴展DynamicObject)?WF4中的動態對象參數活動

當運行一個單元測試調用一個具有動態對象作爲參數的活動時,我得到以下錯誤消息。

使用DynamicObject作爲參數類型

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'.

使用實際類型作爲參數類型

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'.

+0

Ron的帖子是否適合你?如果是這樣,請將其標記爲社區的答案。謝謝! – 2012-08-20 12:46:28

回答

1

是的,這絕對作品。我在Microsoft.Activities.Extensions.WorkflowArguments中創建了這樣一個對象。

嘗試直接指定給活動的InArgument時,遇到的問題可能是錯誤。我寫了一篇關於這個的博客文章Passing arguments to Workflow Activities (again)