State Machine Workflow Does not subscribe to events

I have created a state machine workflow. The state transitions are based on event activites, which listen for events similarly to the method described in the Hands On Lab #4. However, when I call the RaiseEvent functions, the events which they are suppose to raise are null, meaning no one subscribed to listen to them.

Has anyone had this happen to them? Does anyone know what could be wrong?

Amanda

[411 byte] By [AmandaJamin] at [2007-12-21]
# 1

Amanda - this usually means that the state machine workflow isn't in the state you are expecting it to be.

You can find out what state it is in by creating a StateMachineWorkflowInstance and checking the states:

StateMachineWorkflowInstance wi = new StateMachineWorkflowInstance(workflowRuntime,id);//where id is the instance id of your workflow

Console.WriteLine(wi.CurrentState);

You can also see what queues have been created (which will tell you what handleexternalevent activities are listening) by using WorkflowInstance.GetWorkflowQueueData

JonFlanders at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
I have checked the state, and the workflow is in the state that is listening for the event (the JobFinished event).

However, when the following code is reached

public void RaiseJobFinished(string ImageId, Guid instanceId)
{
if (JobFinished != null)
JobFinished(null, new JobEventArgs(instanceId, ImageId));
}

JobFinished (which is a public event EventHandler<JobEventArgs> JobFinished;) is null at this point however.

I cannot figure out why JobFinished is null however. The state is listening for an event of JobFinished which is declared in an interface class. The above funtion is declared in a class that implements the interface.

Amanda

AmandaJamin at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Did you add the ExternalDataExchangeService to the WorkflowRuntime? And your local service to the ExternalDataExchangeService?
JonFlanders at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Thank you, that was the problem.
AmandaJamin at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified