サービスとしてホストされている非常に単純なワークフローがあります。このワークフローからの例外を処理したいだけです。
私のワークフローは、パラメーターとして「string」を取得し、それを int にキャストしようとします。したがって、「asasafs」のようなデータを送信するたびに、失敗して例外がスローされます。とてもシンプルです:)
独自の WorkflowServiceHostFactory を作成できることを読みましたが、残念ながら単純なタスクを達成できません。これが私の実装です。
public class MyServiceHostFactory : System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory
{
protected override WorkflowServiceHost CreateWorkflowServiceHost(Activity activity, Uri[] baseAddresses)
{
return base.CreateWorkflowServiceHost(activity, baseAddresses);
}
protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)
{
var host = base.CreateWorkflowServiceHost(service, baseAddresses);
WorkflowRuntimeBehavior wrb = host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();
if (wrb == null)
wrb = new WorkflowRuntimeBehavior();
wrb.WorkflowRuntime.ServicesExceptionNotHandled += WorkflowRuntime_ServicesExceptionNotHandled;
wrb.WorkflowRuntime.Started += WorkflowRuntime_Started;
wrb.WorkflowRuntime.WorkflowCompleted += WorkflowRuntime_WorkflowCompleted;
host.Description.Behaviors.RemoveAll<WorkflowRuntimeBehavior>();
host.Description.Behaviors.Add(wrb);
host.Faulted += host_Faulted;
host.UnknownMessageReceived += host_UnknownMessageReceived;
return host;
}
void workflowRuntime_WorkflowCreated(object sender, WorkflowEventArgs e)
{
throw new NotImplementedException();
}
void WorkflowRuntime_WorkflowCompleted(object sender, System.Workflow.Runtime.WorkflowCompletedEventArgs e)
{
throw new NotImplementedException();
}
void WorkflowRuntime_Started(object sender, System.Workflow.Runtime.WorkflowRuntimeEventArgs e)
{
throw new NotImplementedException();
}
void WorkflowRuntime_ServicesExceptionNotHandled(object sender, System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs e)
{
throw new NotImplementedException();
}
void host_UnknownMessageReceived(object sender, System.ServiceModel.UnknownMessageReceivedEventArgs e)
{
throw new NotImplementedException();
}
void host_Faulted(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
Visual Studio 2k10 と iisexpress を使用していますが、ワークフローが例外をスローするたびに、デバッガーはどのイベント ハンドラーでも中断しません。適切に行う方法を知っていますか?