views:

69

answers:

1

I was designing an Activity today and I came across an issue by which rethrowing an exception within the Catch of a TryCatch block does not execute the Finally which is also associated with it. Upon further investigation I came across the following

http://connect.microsoft.com/wf/feedback/details/557601/try-catch-activity-never-executes-finally-if-exception-propagates

Can anyone explain to me what the use of the finally block is in this activity if it is not guaranteed to execute?

The only case I can see is if you have nested try blocks.

+3  A: 

if you follow some links from that connect page you will reach this page where you may find an answer... the gist is:

The normal WF functions like

try
{
    Environment.FailFast("Game Over.");
}
finally
{
    Console.WriteLine("Not Called");
}

the solution is (quoting steve danielson from that page): If you specify Cancel as the behavior for unhandled exceptions escaping the root of the workflow then it should give the desired behavior. I have passed this feedback along and will ensure that the documentation is updated to reflect this.

ie Workflowapplication.OnUnhandledException = UnhandledExceptionAction.Cancel

HTH

BioBuckyBall