Input markup invalid  
Author Message
Larkin Y





PostPosted: Windows Workflow Foundation, Input markup invalid Top

I am working through the examples in the book "Essential Windows Workflow Foundation", and I am running across the error "Input markup is invalid" for a .xoml workflow definition file I am using. Below is the code for the While activity class, as well as the custom ActivityCondition class and the console host. Can someone please help me figure out why I am getting this error What gets me is that the workflow designer renders the workflow definition file just fine, but for some reason the WF runtime reports it as invalid..just weird.

While.cs:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace EssentialWF.Activities
{
public partial class While : CompositeActivity
{
public static readonly DependencyProperty
ConditionProperty = DependencyProperty.Register(
"Condition",
typeof(ActivityCondition),
typeof(While),
new PropertyMetadata(DependencyPropertyOptions.Metadata)
);

public ActivityCondition Condition
{
get
{
return GetValue(ConditionProperty)
as ActivityCondition;
}

set
{
SetValue(ConditionProperty, value);
}
}

protected override ActivityExecutionStatus Execute(
ActivityExecutionContext context)
{
if (Condition != null && Condition.Evaluate(this, context))
{
ExecuteBody(context);
return ActivityExecutionStatus.Executing;
}

return ActivityExecutionStatus.Closed;
}

void ExecuteBody(ActivityExecutionContext context)
{
ActivityExecutionContextManager manager =
context.ExecutionContextManager;

ActivityExecutionContext newContext =
manager.CreateExecutionContext(EnabledActivities[0]);

Activity newActivity = newContext.Activity;

newActivity.Closed += this.ContinueAt;
newContext.ExecuteActivity(newActivity);
}

void ContinueAt(object sender,
ActivityExecutionStatusChangedEventArgs e)
{
e.Activity.Closed -= this.ContinueAt;

ActivityExecutionContext context =
sender as ActivityExecutionContext;

ActivityExecutionContextManager manager =
context.ExecutionContextManager;

ActivityExecutionContext innerContext =
manager.GetExecutionContext(e.Activity);

manager.CompleteExecutionContext(innerContext);

if ((this.ExecutionStatus ==
ActivityExecutionStatus.Executing) &&
Condition != null &&
Condition.Evaluate(this, context))
{
ExecuteBody(context);
}
else
{
context.CloseActivity();
}
}
}
}

ConstantLoopCondition.cs:

using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.ComponentModel;

namespace EssentialWF.Activities
{
public class ConstantLoopCondition : ActivityCondition
{
int _counter = 0;

public static readonly DependencyProperty
MaxCountProperty = DependencyProperty.Register(
"MaxCount",
typeof(int),
typeof(ConstantLoopCondition),
new PropertyMetadata(DependencyPropertyOptions.Metadata)
);

public int MaxCount
{
get { return (int)GetValue(MaxCountProperty); }
set { SetValue(MaxCountProperty, value); }
}

public override bool Evaluate(Activity activity, IServiceProvider provider)
{
return (_counter++ < this.MaxCount);
}
}
}


WhileHost.cs:

static void Main()
{
using (WorkflowRuntime runtime = new WorkflowRuntime())
{
TypeProvider typeProvider = new TypeProvider(runtime);
typeProvider.AddAssemblyReference("EssentialWF.dll");
runtime.AddService(typeProvider);

runtime.StartRuntime();

WorkflowInstance instance = null;
using (XmlTextReader reader = new XmlTextReader("WhileTestWF.xoml"))
{
instance = runtime.CreateWorkflow(reader);
instance.Start();
}
}
}

WhileTestWF.xoml:

<While x:Name="while1" xmlns="http://EssentialWF/Activities" xmlns:x=" http://www.hide-link.com/ ; xmlns:wf=" http://www.hide-link.com/ ;>
<While.Condition>
<ConstantLoopCondition MaxCount="3" />
</While.Condition>
<Sequence x:Name="s1">
<ReadLine x:Name="r1" />
<WriteLine Text="{wf:ActivityBind r1,Path=Text}" x:Name="w1" />
</Sequence>
</While>

Any ideas as to why it is telling me the input markup is invalid

Thanks,
Larkin


Software Development for Windows Vista4  
 
 
Larkin Y





PostPosted: Windows Workflow Foundation, Input markup invalid Top

Nevermind--just a stupid mistake. I had moved my .xoml files into a subfolder named "Workflows" under the console project directory, and it was copying those files to the output directory with the "Workflows" folder. Since I was referencing the .xoml file path using just the filename (not "Workflows\SomeXAMLFile.xoml") it wasn't actually finding the file. D'oh!