XAML activation and how to use it

XAML activation is when you use the serialized xoml file to create and run a workflow instance. You will use one of the following WorkflowRuntime methods to create the workflow instance:

public WorkflowInstance CreateWorkflow(XmlReader workflowDefinitionReader);

public WorkflowInstance CreateWorkflow(XmlReader workflowDefinitionReader, XmlReader rulesReader, Dictionary<string, object> namedArgumentValues);

public WorkflowInstance CreateWorkflow(XmlReader workflowDefinitionReader, XmlReader rulesReader, Dictionary<string, object> namedArgumentValues, Guid instanceId);

Activation can be used for sequential or statemachine workflow, samples for each are attached to this post. You are not able to use any code beside. This will require you to add any needed variables or handlers to a compiled type, like your base activity.

The only difference between a xoml file used with activation and one that is compiled into a type is the x:Class attribute. The attribute is used by the workflow author to explicitly state that the workflow must be compiled into a type and to define the class name for that type.

If you are getting an exception when the call to CreateWorkflow is made try the following to help resolve the error(s):

try

{

    WorkflowInstance instance = workflowRuntime.CreateWorkflow(xomlReader, ruleReader, parameters);

    instance.Start();

   waitHandle.WaitOne();

}

catch (WorkflowValidationFailedException exp)

{

    StringBuilder errors = new StringBuilder();

    foreach (ValidationError error in exp.Errors)

    {

        errors.AppendLine(error.ToString());

    }

    MessageBox.Show(errors.ToString(), "Workflow Validation Errors");

}

To bind to an event or condition handler in the base workflow you will need to manually update the xoml file since you can’t use the designer to do this. The syntax to use is the following:

      EventOrConditionName="{ActivityBind NameOfWorkflowInstance,Path=EventOrConditionHandler}"

This posting is provided "AS IS" with no warranties, and confers no rights.

XAMLActivation.exe