locked
Using CreateWorkflow(XmlReader Xamlreader) RRS feed

  • Question

  • I am working with WF 4.0 and trying to use WorkflowRuntime.CreateWorkflow(XmlRead reader). But WHen I try to load My flochart XAML it fails validation eventhough it only contains a delay activity. What am I doint wrong here?

    Code:
    XmlReader wfReader = XmlReader.Create(@"C:\AgentTest\Flowchart1.xaml");
    return wfRuntime.CreateWorkflow(wfReader).InstanceId;

    results in:
    Test method AgentTest.AgentServiceTest.LoadWorkflowTest threw exception: System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation.

    workflow XAML:
    <p:Activity mc:Ignorable="" x:Class="AgentTest.Flowchart1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__Flowchart1="clr-namespace:AgentTest;" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <p:Flowchart StartNode="{x:Null}" sad:XamlDebuggerXmlReader.FileName="C:\AgentTest\Flowchart1.xaml">
        <WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, s:Object">
            <av:Point x:Key="ShapeLocation">275,10</av:Point>
            <av:Size x:Key="ShapeSize">50,50</av:Size>
          </scg:Dictionary>
        </WorkflowViewStateService.ViewState>
        <p:FlowStep>
          <WorkflowViewStateService.ViewState>
            <scg:Dictionary x:TypeArguments="x:String, s:Object">
              <av:Point x:Key="ShapeLocation">195,103</av:Point>
              <av:Size x:Key="ShapeSize">200,34</av:Size>
            </scg:Dictionary>
          </WorkflowViewStateService.ViewState>
          <p:Delay>[TimeSpan.MinValue]</p:Delay>
        </p:FlowStep>
      </p:Flowchart>
    </p:Activity>
    Thursday, September 10, 2009 4:15 AM

Answers

  • Hi,

    - you cannot use WF3 loader for WF4 xaml resource.
    Have a look at the System.Activities.WorkflowXamlServices and System.Activities.WorkflowInstance classes for creating an instance from xaml resource.

    -
    your flowchart has two errors:
        1. missing a StartNode  (missing a start connection in the layout)
        2. Delay argument cannot be negative (use for instance: TimeSpan.FromSeconds(5) )

    Thanks

    Roman
    Roman Kiss, MVP Connected System Developer
    Thursday, September 10, 2009 6:59 AM

All replies

  • Hi,

    - you cannot use WF3 loader for WF4 xaml resource.
    Have a look at the System.Activities.WorkflowXamlServices and System.Activities.WorkflowInstance classes for creating an instance from xaml resource.

    -
    your flowchart has two errors:
        1. missing a StartNode  (missing a start connection in the layout)
        2. Delay argument cannot be negative (use for instance: TimeSpan.FromSeconds(5) )

    Thanks

    Roman
    Roman Kiss, MVP Connected System Developer
    Thursday, September 10, 2009 6:59 AM
  • Fixed. I was trying to do WF 4 old schoo style
    Wednesday, September 16, 2009 5:17 AM