Custom configuration for custom exception handler

Topics: Building and extending application blocks, Exception Handling Application Block
Apr 14, 2008 at 5:56 PM

I wrote a new exception handler for the EHAB that sends an e-mail message containing the exception info to a list of recipients. Since I like things to be easy to use I'd like to configure all the necessary settings (smtp server, sender address, recipient addresses, mail subject, mail text, ...) using the property grid in the EntLib config tool and not just error-prone key-value pairs.

So I took a look into the EntLib implementation of the LoggingHandler and the LoggingHandlerData and created my own SendMailExceptionHandlerData according to what i found there.

When I tried to add my new custom handler using the config tool it did not display my SendMailExceptionHandler in the custom handler type selection window.

When I replace

public class SendMailExceptionHandler : IExceptionHandler


public class SendMailExceptionHandler : IExceptionHandler

the custom handler type selection window shows my custom handler.

The next thing I tried to do is not to derive SendMailExceptionHandlerData from ExceptionHandlerData but from CustomHandlerData but this didn't work either.

Does anyone know how I can make this work?
Apr 14, 2008 at 6:59 PM

The ConfigurationElementType attribute determines how the configuration file gets deserialized, but it doesn't influence the configuration tool. In a nutshell, when the configuration file parser finds a new "add" element it will look for a "type" attribute, load it and try to extract the ConfigurationElementType to determine the type of configuration object to hydrate with the configuration XML.

Design-time nodes and the supporting code are defined in separate assemblies, and glue code is necessary to map from configuration objects to nodes and viceversa, and to let the user create new nodes (through UI Commands). You can take a look at the ExceptionHandling.Logging* set of projects for an example of what you'd need to do.