Do you want to invoke another workflow but you won't know which one until runtime?

The InvokeWorkflowActivity that ships with WF requires you to set the type of the target workflow at design time. If you won’t know which workflow to invoke until runtime you need to write a custom activity. To invoke a workflow need to use the IStartWorkflow service that you can get from the ActivityExecutionContext, like the following:

IStartWorkflow startWorkflow = executionContext.GetService(typeof(IStartWorkflow)) as IStartWorkflow;

Guid instanceId = startWorkflow.StartWorkflow(this.TargetWorkflow, this.Parameters);

Since the parameters won’t be known until runtime you can’t use the WorkflowParameterBindingsCollection because you wouldn’t be able to change in at runtime. Instead I have have a parameters property that is type Dictionary<string, object>.

CustomInvokeWorkflowActivity.exe