Hi,
So, my code has been working ok. I have a state-safe workflow, which means that if the workflow engine stops and unloads, then it should be able to start back where I left it.
There are some stages that perform some setup (such as subscribing to events for eg) which I need to make sure is done if the workflow is loaded in a later stage.
For example:
Tracker Workflow Starts:
state1: setup (subscribe to events)
state2: wait for event (requires subscription to event)
state3: report back to parent workflow
if the workflow is stopped (shutdown / crash) at stage 2, then I need to resubscribe to the event.
I added a method to the baseclass of the stages that runs only if the workflow is reloaded from a shutdown state. I can override it in state2 and resubscribe.
If I do not shut down the workflow, the following code runs fine:
public static IWorkflow LoadWorkflow(Workflow workflowInfo)
{
Type type = LoadWorkflowType(workflowInfo);
MethodInfo method = type.GetMethod("DeSerialize", Flags);
if (method == null && type.BaseType != null)
method = type.BaseType.GetMethod("DeSerialize", Flags | BindingFlags.InvokeMethod).MakeGenericMethod(type);
if (method == null)
throw new NullReferenceException("No DeSerialize method found!");
IWorkflow workflow = (IWorkflow)method.Invoke(type, new object[] { workflowInfo });
return workflow;
}
If I do restart it then I get an error at the invocation:
Quote:
Object of type 'WorkFlowEngine.Projections.Workflow' cannot be converted to type 'WorkFlowEngine.Projections.Workflow'.
I
think that this is because one version of the assembly is loaded at runtime (
Type type
), whilst the other is a direct reference (the input parameter of "
Deserialize
").
i would like to convert the loaded version of
type
to the referenced version of
'WorkFlowEngine.Projections.Workflow'
.
Is that even possible?
Is there a better way I can do this?
Thanks ^_^
Andy