I want to stop processing a Sequential workflow if an activity fails....

I want to stop processing a Sequential workflow if a single activity fails....

How do I force it to stop processing everything else?

Any help would be appreciated.

Thanks

[176 byte] By [Davidd] at [2007-12-23]
# 1

Your question does not say how the 'failure' is manifested in the workflow - is it a return value or an exception?

If it's an exception you would add a FaultHandlerActivity in the Fault Handlers View of your workflow. Set the exception type to the expected type of exception and add a Terminate activity to it.

If it's just an invalid/error return value, then you could just write code to cancel the workflow, or a nicer way would be to throw your own exception, and let the FaultHandler pick it up and terminate.

HowardRichards at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
I'm new to this whole Workflow foundation.

Can you tell me where to go to find information on how to set up a FaultHandler?
I see it the designer, I just want to make sure I set it all correctly.

Thanks.

Davidd at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

Take a look at Mike Taulty's excellent screencast 'nuggets'

http://wf.netfx3.com/files/folders/screencasts/entry4975.aspx

This one shows how to handle exceptions for either the whole workflow, or a localised exception for just particular sequence.

HowardRichards at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Thanks this helped!

However, I added a Fault Handler to the SequenceActivity and it's writing out the log entry that an exception occured according to the CodeActivity I defined. But it's not stopping the workflow.

I have a WhileActivity.. Should I place the Fault Handler there instead to stop the While from continuing?

Thanks for all your help!

Davidd at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

did you really use a Terminate activity in your Fault Hanlder ?

SergeLuca at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6
I have not used a Terminate Activity...
Should I ?

I am currently calling
throw ApplicationException("Application Exeception occured");

inside my ifElseBranchActivity Event for Failure.
and then using the FaultHandler inside the Sequence Activity to catch the ApplicationException.

but It doesn't stop the it from running other Activities in that same workflow, I guess since it's inside the WhileActivity.

Davidd at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 7
Yes, the FaultHandler picks up the error, and can contain other activities within it.. just drag a Terminate activity into the FaultHandler and it should work.
HowardRichards at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified