O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling errors

In this task, we are going to create a Sequence workflow with a TryCatch activity. There will be a dividend assigned with zero, and hence we can generate a divide-by-zero exception deliberately so that we can handle this error in a TryCatch activity.

How to do it...

  1. Create a workflow project:

    Create a new Workflow Console Application and name it ErrorHandling.

  2. Create a code workflow:

    Create a new class file and name it ErrorHandlingWorkflow.cs. Fill the file with the following code:

    using System; using System.Activities; using System.Activities.Statements; namespace ErrorHandling { public class ErrorHandlingWorkflow{ public Activity GetInstance() { Variable<int> divisor = new Variable<int>("divisor", 10); Variable<int> dividend = new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required