Posts Tagged ‘WF’

If your Activities OutArgument is something complex,say List<string> for eg,then you need to initialize it first & If you don’t do so,you will get an exception The property ‘Collection’ of ‘AddToCollection<String>’ is not initialized.

For assigning default value to the variable,you can use the assign activity & initialize it to New List(Of String).Though your language is C#,if you look at,you will understand that the initialization to variable is a VB expression ! It’s not a big deal to write an expression in VB ,still I wonder why is it so when the project is C# :)If you know the answer,please share  that in the comments section below 🙂


WorkflowInvoker class provides a means for invoking a workflow as if it were a method call.

Assembly:System.Activities (in System.Activities.dll)

A custom activity example which we will call using WorkFlowInvoker :

public sealed class SendEmailActivity : CodeActivity

public InArgument Subject { get; set; }

public InArgument Body { get; set; }

public InArgument To { get; set; }

public InArgument From { get; set; }

protected override void Execute(CodeActivityContext context)
// Obtain the runtime value of the Subject input argument
string text = context.GetValue(this.Subject);

Invokes SendEmailActivity :
public void TestSendEmailActivity()

WorkflowInvoker invoker = new WorkflowInvoker(
new SendEmailActivity
From = "",
To = "",
Subject = "Hello",
Body="How are you?"