If you define your rules in Visual Studio, thereby creating a .rules file associated with your workflow, the runtime finds this file and uses it when your workflow is executed - that is, if your workflow is started by pointing to a .NET class type in the WorkflowRuntime.CreateWorkflow method.
With the XAML workflow style, on the other hand, you can specify the rules XML to be used when you call the CreateWorkflow method. The following code is an example of how this is done:
WorkflowRuntime workflowRuntime = new WorkflowRuntime(); XmlReader workflowReader = XmlReader.Create("MyWorkflow.xoml"); XmlReader rulesReader = XmlReader.Create("MyWorkflowRules.xoml"); WorkflowInstance instance = workflowRuntime.CreateWorkflow( workflowReader, rulesReader, null); instance.Start();
There is an overload of the CreateWorkflow method that takes two XmlReader instances: one for the workflow definition itself and one for the workflow rules. The preceding code uses this method to create a workflow instance from the MyWorkflow.xoml definition file, with the rules that are in the MyWorkflowRules.xoml file.