Vista Squad Home

Vista Squad


The Usergroup for Windows Vista and the .NET Framework 3.0 and 3.5.

Welcome to Vista Squad Sign in | Join | Help
in
Home Blogs Forums Photos Downloads

Handling exceptions with FaultHandlers - inconsistent debug behaviour

Last post 04-27-2007, 9:08 by DoctorT. 0 replies.
Sort Posts: Previous Next
  •  04-27-2007, 9:08 203

    Handling exceptions with FaultHandlers - inconsistent debug behaviour

    Workflow provides a FaultHandlerActivity to handle exceptions thrown during the execution of the workflow. This is a generic model that is true for both state machine and sequential workflows.

    I noticed something strange behaviour when debugging a fault handler in a sequential workflow. The fault property, which contains the exception information, was not populated in the debug/immediate windows. Having looked on the forums, this scenario was found by someone else http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1436473&SiteID=1.

    Looking into the way in which exceptions are managed in WF provides a partial answer to this behaviour. When an exception is thrown within the workflow, this is handled by the runtime and the exception put into a dependency property named ActivityExecutionContext.CurrentExceptionProperty. When the Execute method is fired for the FaultHandlersActivity (the composite activity which can contains multiple FaultHandlerActivity), it reads the exception from the dependency property and populates the Fault property of each of the child FaultHandlerActivity activities. This dependency property is then removed.

    When debugging the sequential workflow fault handler, the state of the FaultHandlersActivity was set to Initialized. Since the Execute method had yet to be invoked, the Fault property was not populated. The debugger behaves differently for state machine and sequential workflows, but the runtime mechanism for handling exception is the same.

    Filed under:
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems Sign up for MSDN Flash Newsletter and win a Prize! Ineta
Sponsored By Dot Net Solutions Ltd