Question

I'm currently using a BehaviorExtensionElement to load a ServiceBehavior where the ApplyDispatchBehavior method is set up as:

    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
    {
        WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost;
        if (host != null)
        {
            UnityService.CreateContainer();
            host.WorkflowExtensions.Add<IUnityContainer>(delegate { return UnityService.CreateChildContainer(); });

            System.Diagnostics.Debug.WriteLine("NotificationService : Adding extension");

            WorkflowRuntimeBehavior wfbehavior = serviceDescription.Behaviors.Find<WorkflowRuntimeBehavior>();
            WorkflowRuntime runtime = wfbehavior.WorkflowRuntime;

            runtime.WorkflowStarted += runtime_WorkflowStarted;
            runtime.WorkflowCreated += runtime_WorkflowCreated;

            runtime.WorkflowUnloaded += runtime_WorkflowUnloaded;
            runtime.WorkflowSuspended += runtime_WorkflowSuspended;

            runtime.WorkflowCompleted += runtime_WorkflowCompleted;
            runtime.WorkflowAborted += runtime_WorkflowAborted;
            runtime.WorkflowTerminated += runtime_WorkflowTerminated;
        }
    }

None of the events are triggered which only goes to say that the way I'm referencing the runtime instance in this particular scenario is wrong.

Anyone know of a way to do this? Thanks in advance.

Was it helpful?

Solution

The WorkflowRuntime and WorkflowRuntimeBehavior are WF3 artifacts but your question is tagged as WF4 so I will presume you are using WF4.

In WF4 the way to do this is by using a custom TrackingParticipant and adding that to the WorkflowExtensions collection of the WorkflowServiceHost.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top