Partager via


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

Comments

  • Anonymous
    May 02, 2006
    ASP.NET 2.0: Implementing Single Sign On (SSO) with
    Membership API [Via: sahilmalik ]
    Atlas Control...

  • Anonymous
    October 08, 2006
    PingBack from http://ajlopez.wordpress.com/2006/10/09/learning-windows-workflow-foundation/

  • Anonymous
    October 08, 2006
    En estos dias, he ordenado algunos enlaces y recursos sobre el Windows Workflow Foundation, el motor

  • Anonymous
    August 14, 2008
    Could you elaborate or provide an example of "add any needed variables or handlers to a compiled type" I believe I need to take this approach instead of XAML activation.  Here is my process...

  • get workflow template from database
  • deserialize it
  • get list of approvers from table
  • add activity for each approver
  • compile?
  • instantiate