locked
WorkflowServiceHost - How can I catch unhandled workflow exceptions? RRS feed

  • Question

  • I might miss something obvious, but how do I catch unhandled exceptions in a workflow running in WorkflowServiceHost?

    WorkflowInstance has an OnUnhandledException property, WorkflowServiceHost does not. Why not? I might try to evaluate tracking events to detect exceptions, but I think there must be an easier way.
    Thank you.
    Sunday, June 14, 2009 12:11 AM

Answers

  • There is a good sample for you in the WF/WCF 4 samples - in the root of the samples, go to the following folders: WF\Application\DocumentApprovalProcess\CS. If you look in the ApprovalManager project, there is sample code that uses WorkflowServiceHost and catches exceptions using a DurableServiceHostExtension.

    Program.cs loads the WorkflowServiceHost and adds the SHExceptionOutput class as an extension. Go into SHExceptionOutput.cs to see where it logs details about unhandled exceptions.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Tuesday, June 16, 2009 7:32 PM
  • Hi,
    Just a FYI...the DurableServiceHostExtension is being removed in Beta2 so although it is the means to catch exceptions in Beta1 moving forward you will want to use a custom tracking participant and then add that participant to the WorkflowServiceHost's WorkflowExtensions.

    Thanks,
    Amy
    Tuesday, June 16, 2009 7:50 PM

All replies

  • There is a good sample for you in the WF/WCF 4 samples - in the root of the samples, go to the following folders: WF\Application\DocumentApprovalProcess\CS. If you look in the ApprovalManager project, there is sample code that uses WorkflowServiceHost and catches exceptions using a DurableServiceHostExtension.

    Program.cs loads the WorkflowServiceHost and adds the SHExceptionOutput class as an extension. Go into SHExceptionOutput.cs to see where it logs details about unhandled exceptions.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Tuesday, June 16, 2009 7:32 PM
  • Hi,
    Just a FYI...the DurableServiceHostExtension is being removed in Beta2 so although it is the means to catch exceptions in Beta1 moving forward you will want to use a custom tracking participant and then add that participant to the WorkflowServiceHost's WorkflowExtensions.

    Thanks,
    Amy
    Tuesday, June 16, 2009 7:50 PM