2013-08-27 29 views
0

我正在使用Windows Workflow Foundation 4.5。如何将参数传递到代码中的工作流活动?

我想将参数传递给WriteLine活动。代码如下:

class Program 
{ 
    static void Main(string[] args) 
    { 
     WriteLine wf1 = new WriteLine(); 
     wf1.Text = "arg1"; 

     Dictionary<String, Object> arg = new Dictionary<String, Object>(); 
     arg.Add("arg1", "Hello,world!"); 

     WorkflowInvoker.Invoke(wf1, arg); 
    } 
} 

,但我得到在运行时出现以下错误:

Unhandled Exception: System.ArgumentException: The values provided for the root activity's arguments 
did not satisfy the root activity's requirements: 
'WriteLine': The following keys from the input dictionary do not map to arguments and must be remove 
d: arg1. Please note that argument names are case sensitive. 

那么什么是做了正确的方法是什么?

回答

1

参数的名称是“文本”。这将工作:

class Program 
{ 
    static void Main(string[] args) 
    { 
     WriteLine wf1 = new WriteLine(); 

     Dictionary<String, Object> arg = new Dictionary<String, Object>(); 
     arg.Add("Text", "Hello,world!"); 

     WorkflowInvoker.Invoke(wf1, arg); 
    } 
} 
+0

谢谢,它的作品! – smwikipedia

+0

现在我明白为什么输入参数的类型是Dictionary 。这样,我可以通过映射到其公共属性的名称将任何类型传递到工作流中。 – smwikipedia

相关问题