Walkthrough: Processing and Resuming Execution

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

This walkthrough demonstrates the steps to run a series of exception handlers before resuming execution in the application. Figure 1 illustrates the process.

Ff649173.e26218cf-db86-4669-b0bd-94908ef63370(en-us,PandP.10).png

Figure 1
Processing and resuming execution

The QuickStart executable calls a method in the business layer assembly, and an exception occurs. The Exception Handling Application Block uses the specified policy—Handle and Resume Policy—to handle the exception.

The policy is configured so that exceptions of type System.Exception have a PostHandlingAction of None. This causes the Exception Handling Application Block to return false to the business layer. When it detects that the return value is false, the business layer resumes execution.

To reproduce this scenario

  1. Create a new blank solution in Visual Studio.
  2. Add a Windows-based application project named ExceptionHandlingBasicQuickStart to the solution.
  3. Add a class library project named ExceptionHandlingQuickStart.BusinessLayer to the solution.
  4. Rename the class in ExceptionHandlingQuickStart.BusinessLayer to AppService.
  5. Add the ProcessC and ProcessAndResume methods to the AppService class. These methods are included in the QuickStart source code.
  6. Import the System.Security class and the System.Security.Principal namespace. These are used by ProcessC.
  7. Use the configuration tools to create a new application configuration file.
  8. Use the configuration tools to add the Exception Handling Application Block configuration to the application.
  9. Add a new exception policy named Handle and Resume Policy.
  10. Add the exception type System.Exception to the Handle and Resume Policy.
  11. Configure the System.Exception exception type to have a PostHandlingAction of None.