我目前正在使用chativiorextensionElement来加载服务行为,其中设置了applydispatchbehavior方法为:

    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;
        }
    }

没有触发这些事件,只能说我在这种特定方案中引用运行时实例的方式是错误的。

有人知道这样做的方法吗?提前致谢。

有帮助吗?

解决方案

WorkFlowRuntime和WorkFlowRuntimeBehavior是WF3工件,但您的问题被标记为WF4,因此我想您正在使用WF4。

在WF4中,这样做的方法是使用自定义跟踪参与者,并将其添加到WorkflowserviceHost的WorkFlowExtensions集合中。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top