Migration 4.1 to 5.0

Topics: Building and extending application blocks, Exception Handling Application Block
Apr 4, 2013 at 4:59 PM
Hello guys !

Today, I receive my new week task, and I may migrate the Project from EntLib 4.1 to Entlib 5.0 and from Unity 1.2 to Unity 2.0.

Unfortunatly, I never work with Entlib before today, so it's a little bit hard for me.

I try to convert the first project in my solution, but after a lot of search on the web I don't find the answer for my question.

The code seem like this at the begining
    public class LoggingExceptionHandlerData : ExceptionHandlerData

public class LoggingExceptionHandlerAssembler : IAssembler<IExceptionHandler, ExceptionHandlerData>
       public IExceptionHandler Assemble(IBuilderContext context,
                                          ExceptionHandlerData objectConfiguration,
                                          IConfigurationSource configurationSource,
                                          ConfigurationReflectionCache reflectionCache)
Now it look like this
    public class LoggingExceptionHandlerData : ExceptionHandlerData

public class LoggingExceptionHandlerAssembler : IExceptionHandler
        public override IEnumerable<TypeRegistration> GetRegistrations(IBuilderContext context,
                                          ExceptionHandlerData objectConfiguration,
                                          IConfigurationSource configurationSource)
But unfortunatly it doesn't work fine.

Questions :
How work the GetRegistrations method ?
My code is good ?
Apr 5, 2013 at 5:14 AM
Edited May 1, 2013 at 9:30 PM
The code you posted looks like Enterprise Library source code. Have reused the Enterprise Library source code to create custom functionality?

If so, then a good approach would be to download the 4.1 and 5.0 source code -- it can help in seeing what was done between versions especially if you are using Enterprise Library internal classes such as LoggingExceptionHandlerAssembler.

In terms of GetRegistrations I would guess you would want something similar to:
        public override IEnumerable<TypeRegistration> GetRegistrations(string namePrefix)
            yield return new TypeRegistration<IExceptionHandler>(
                () =>
                new LoggingExceptionHandler(LogCategory, EventId, Severity, Title, Priority, FormatterType,
                           Name = BuildName(namePrefix),
                           Lifetime = TypeRegistrationLifetime.Transient
Except that you would instantiate your custom LoggingExceptionHandler.

Randy Levy
Enterprise Library support engineer
Support How-to
Apr 5, 2013 at 8:15 AM
The problem when I compile my code, is the override GetRegistrations() methods does not exist in IExceptionHandler interface.

How to extend the ExceptionHandlerData in EntLib 5.0 ?

I download the "Enterprise_Library_Extensibility_Hands-On_Labs" with a lot of project inside, but no one help me to understand how extend ExceptionHandlerData.

Can anyone help me ?

PS : Thank's randylevy for the quick reply
Apr 5, 2013 at 1:52 PM
I think, I found a answer to my problem.

The second class does not exist yet, I delete it, and I create the GetRegistration method in the first.

I don't now if the problem is resolve but I compile.

Thanks to read me