Question:
1 ) This Workflow have base workflow and CustomActivity
in Project Workflow.Base
public partial class BaseWorkflow : SequentialWorkflowActivity{private bool _Result;public bool Result{get { return _Result; }set { _Result = value; }}private string _WorkflowName;public string WorkflowName{get { return _WorkflowName; }set { _WorkflowName = value; }}}public partial class MessageBoxActivity :Activity{private string message;public string Message{get { return message; }set { message = value; }}protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext){MessageBox.Show(this.message);return ActivityExecutionStatus.Closed;}}
2) I Create TestBaseWorkflow.xoml and TestBaseWorkflow.rules
TestBaseWorkflow.xoml:
<ns0:BaseWorkflow x:Name="TestBaseWorkflow" Result="False" WorkflowName="{x:Null}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ns0="clr-namespace:Workflow.Base;Assembly=Workflow.Base, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null"><IfElseActivity x:Name="ifElseActivity1"><IfElseBranchActivity x:Name="ifElseBranchActivity1"><IfElseBranchActivity.Condition><RuleConditionReference ConditionName="Condition1" /></IfElseBranchActivity.Condition><ns0:MessageBoxActivity Message="true" x:Name="messageBoxActivity1" /></IfElseBranchActivity><IfElseBranchActivity x:Name="ifElseBranchActivity2"><ns0:MessageBoxActivity Message="fasle" x:Name="messageBoxActivity2" /></IfElseBranchActivity></IfElseActivity></ns0:BaseWorkflow>TestBaseWorkflow.rules:<RuleDefinitions xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"><RuleDefinitions.Conditions><RuleExpressionCondition Name="Condition1"><RuleExpressionCondition.Expression><ns0:CodePrimitiveExpression xmlns:ns0="clr-namespace:System.CodeDom;Assembly=System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><ns0:CodePrimitiveExpression.Value><ns1:Boolean xmlns:ns1="clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">true</ns1:Boolean></ns0:CodePrimitiveExpression.Value></ns0:CodePrimitiveExpression></RuleExpressionCondition.Expression></RuleExpressionCondition></RuleDefinitions.Conditions></RuleDefinitions>
3) Run TestBaseWorkflow
//add Project Workflow.Base's DLL(Include class BaseWorkflow and MessageBoxActivity )TypeProvider typeProviderWorkflow = new TypeProvider(workflowRuntime);typeProviderWorkflow.AddAssembly(typeof(Workflow.Base.BaseWorkflow).Assembly);workflowRuntime.AddService(typeProviderWorkflow);string xomlFile = @"C:\Documents and Settings\Administrator\Desktop\code\BaseWorkflowFoundionSolution\Workflow.TestBase\TestBaseWorkflow.xoml";string rulesFile = @"C:\Documents and Settings\Administrator\Desktop\code\BaseWorkflowFoundionSolution\Workflow.TestBase\TestBaseWorkflow.rules";XmlTextReader readerWf = new XmlTextReader(xomlFile);XmlTextReader readerRules = new XmlTextReader(rulesFile);WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(readerWf, readerRules, new Dictionary<string, object>());workflowInstance.Start();waitHandle.WaitOne();4) catch Exception Message:
An unhandled exception of type 'System.NullReferenceException' occurred in System.Workflow.Runtime.dll
Additional information: Object reference not set to an instance of an object.
5) what can i do run TestBaseworkflow

RunWorkflow from *.xoml ,*.rules?
Doeb
Abort Syntax
It ran without any exceptions and the message box popped up with “true” as the text. Can you change your code to the following and post the output:
try
{
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(readerWf, readerRules, new Dictionary<string, object>());
workflowInstance.Start();
}
catch (Exception exp)
{
Console.WriteLine(exp.StackTrace);
}
Without the stack trace it is impossible to determine the cause of your NullReferenceException.
Hugo from Holland
Sajal57918
Thx tom.I have another quesion.
if I will run workflow in WorkflowMarkupSerializer,where can i use TestBaseWorkflow.rules file
code:
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(wf1.GetType());Randy Trihydro
Sorry Tom , I didn't found the error before .I didn't bulid this project ,and only use file path to run workflow.This Project only include two files (TestBaseWorkflow.xoml and TestBaseWorkflow.rules)TestBaseWorkflow.xomlbulid error is :Cannot compile a markup file which does not contain declaration of the new workflow type.why have this errorcan u send this test project to me (caixikai@hotmail.com)G Unot!
The code build on Beta 2 and didnt get any exceptions.
but if u run the code ,u can catch this exceptions .
Futura57
You dont need to build a xaml only workflow. That is the whole point of having a xaml only workflow. Can you exactly try what Tom has suggested the previous post and let us know what error are you seeing.
nonoandy
I try tom' suggestion.
Runing project is ok.
I only remove Workflow.Base.Test Project's refernce from project workflow.base.Test.Console .
Workflow.Base.Test Project only have TestBaseWorkflow.xoml and TestBaseWorkflow.Rules.
Thx tom and Vihang 's help.
But i cannt bulid TestBaseWorkflow.xoml and TestBaseWorkflow.Rules to DLL file.
I will use it in my engine.
Buliding two files have the previous error.
what can i do
Puneet Minda