我正在使用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.
那么正确的方法是什么?
答案 0 :(得分:1)
参数的名称是“Text”。这将有效:
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);
}
}