CreateWorkflow failing validation
I am trying to start a workflow using a xoml file. I am getting Workflow failed validation in CreateWorkflow with a very simple workflow containing start, delay 1 sec and stop. Is there a trick in getting this to work? Thanks.
// create and start an instance of the workflow runtimeWorkflowRuntime runtime =newWorkflowRuntime();runtime.StartRuntime();
// get an XML reader to the XAML-based workflow definitionSystem.Xml.
XmlReader xaml = System.Xml.XmlTextReader.Create(txtWorkflowFile.Text);// create a running instance of our workflowWorkflowInstance instance;try{
instance = runtime.CreateWorkflow(xaml);
instance.Start();
}
catch (Exception ex){
MessageBox.Show(ex.Message);}
Jon,
Here is the XOML file. If we strip the x:Class="WorkflowDesignerControl.CustomWorkflow" from the Xoml then we execute fine.
<?xml version="1.0" encoding="utf-8"?>
<SequentialWorkflowActivity x:Name="CustomWorkflow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow" x:Class="WorkflowDesignerControl.CustomWorkflow">
<DelayActivity TimeoutDuration="00:00:05" x:Name="Sleep" />
</SequentialWorkflowActivity>
error 1564: x:calss cannot be used when the markup is executed directlywithout creating a new activity type.
I also saw some code that talked about serilizing and deserilizing the XOML...
Thanks.
Right - there are two kind of XAML.
Executable XAML - this is XAML where you can get back an Activity Tree from calling WorkflowRuntime.CreateWorkflow.
Compilable XAML - this XAML that can be compiled into a new Activity type (either in VS.NET, via the WFC tool or WorkflowCompiler class).
Executable XAML cannot have the Class attribute. Compilable XAML *must* have the Class attribute. Executable XAML cannot have any inline code, compilable XAML can. There are of course other differences as well - but those are the main two.
Thank you for the clarification.
Here is the problem:
1. The designer creates a XOML with x:Class
2. We can strip this out and create a new XOML and get it to execute
3. But the Workflow monitor then complains because it uses the designer and the XOML stored at run time is missing the X:Class and this we do not have control over.
Thoughts?