Export (0) Print
Expand All

Entering Configuration Information

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.

These procedures explain how to configure the Exception Handling Application Block. Properties associated with the nodes appear in the right pane.

To add the Exception Handling Application Block

  1. Open the configuration file. For more information, see Configuring the Application Blocks.
  2. Right-click Application Configuration, point to New, and then click Exception Handling Application Block.

To configure an exception handling policy

  1. To add an exception handling policy, right-click the ExceptionHandlingApplicationBlock node, point to New, and then click ExceptionPolicy. This creates an exception handling policy node. By default, this exception policy is named Exception Policy.
  2. Rename the policy (optional). Right-click the policy node, click Rename, and then type the policy name you want.
  3. To add an exception type to a policy, right-click the policy node, point to New, and then click ExceptionType. Select the exception type in the Type Selector dialog. If the type you want is not listed, click LoadAssembly on the TypeSelector dialog to find the assembly that contains the type you want. Click OK. This creates the Exception node. The node's properties are displayed in the right pane.
  4. Select the PostHandlingAction you want. The PostHandlingAction determines what action will occur after the exception handling chain completes. By default, the PostHandlingAction is set to NotifyRethrow. The possibilities are the following:

    None. The application block executes all handlers for this exception and returns false to the application at the point that the HandleException method was invoked. Applications checking this value resume execution.

    NotifyRethrow. The application block executes all handlers for this exception and returns true to the application at the point that the HandleException method was invoked. Applications checking this value rethrow the original exception.

    ThrowNewException. The application block executes all handlers for this exception and throws the exception that exists after the final handler runs.

  5. To add an exception handler, right click the Exception node, point to New, and then click the exception handler type that you want:

    Custom Handler. This exception handler lets you configure custom exception handlers. Click LoadAssembly on the Type Selector to add a custom handler.

    Logging Handler. This exception handler formats exception information and uses the Logging Application Block to log exception information. The Logging Application Block is automatically added to the application configuration when you select a logging handler. For more information, see the Logging Application Block documentation.

    Replace Handler. This exception handler replaces one exception with another.

    Wrap Handler. This exception handler wraps one exception within another exception.

Configuring Exception Handlers

After you add an exception handler to the exception, you can configure it. These procedures explain how to configure custom, logging, replace, and wrap exception handlers.

To configure a custom exception handler

  1. Click the custom handler node in the tree view.
  2. Click the ellipsis button (…) in the Attributes property section of the right pane.
  3. In the EditableKeyValueCollectionEditor dialog box, click Add to add a new name/value pair.
  4. In the right pane of the EditableKeyValueCollectionEditor dialog box, enter the key name and the value of the property.
  5. Add more name/value pairs as appropriate, and then click OK.
  6. In the Name property section located in the right pane of the configuration console, change the name of the exception handler if you want to. The default name is Custom Handler.
  7. Click the ellipsis button (…) in the Type property section of the right pane. If the type you want is not included in the Assemblies folder, click LoadAssembly on the TypeSelector to find the assembly that contains the type you want.

To configure a logging exception handler, click the Logging Handler node and enter the following values that are displayed in the right pane:

    • EventID. This is the ID number of the event that will be logged. The default value is 100. You can enter a different value if you want.
    • FormatterType. This is the fully qualified name of the formatter used to format the exception information before it is logged. Click the ellipsis button (…) and use the TypeSelector to choose the formatter you want to use.
    • LogCategory. This is the name of the log category that the event is assigned to. The default name is DefaultCategory. You can enter the name of a different category if you want to.
    • Name. This is the name of the logging exception handler. The default name is LoggingHandler. You can change the name if you want to.
    • Priority. This is the priority of the log message. The Logging Application Block can be configured to filter log messages depending on their priority.
    • Severity. This is the severity of the event. The default value is Error. To select another level of severity, click an entry in the drop-down list. The other choices are Critical, Warning, Information, Verbose, Start, Stop, Suspend, Resume, and Transfer.
    • Title. This is the title of the log entry. The default value is EnterpriseLibraryExceptionHandling. You can change the title if you want to.

    To configure a replace handler, click the Replace Handler node and enter the following values that are displayed in the right pane:

      • ExceptionMessage. This is the text of the message to be used with the replacement exception. This property is optional.
      • Name. This is the name of the replace handler. The default name is ReplaceHandler. You can change the name if you want to.
      • ReplaceExceptionType. This is the fully qualified name of the exception type that will replace the original exception. The default type is System.Exception. If this is not correct, use the TypeSelector to click the type you want.

      To configure a wrap handler, click the Wrap Handler node and enter the following values that are displayed in the right pane:

        • ExceptionMessage. This is the text of the message to be used with the wrapping exception. This property is optional.
        • Name. This is the name of the wrap handler. The default name is WrapHandler. You can change the name if you want to.
        • WrapExceptionType. This is the fully qualified name of the exception type that will wrap the original exception. The default type is System.Exception. If this is not correct, use the TypeSelector to click the type you want.

        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.
        Show:
        © 2014 Microsoft