What happened with the Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel namespace?

Topics: Enterprise Library Core
Dec 12, 2014 at 12:02 PM
Hi all

I'm trying to extend Enterprise Library and I'm following the hands-on lab found here:
The lab uses Enterprise Library 5, and in one project it uses the method ResolvedIfNotNull from the class Container that is located in the namespace cited in the subject.
But It looks like, in Enterprise Library 6, this namespace doesn't exists anymore.
What I want to know is if, in Enterprise Library 6, the class was renamed or the method ResolvedIfNotNull is located in another class.

Thanks for your attention.
Dec 12, 2014 at 12:45 PM
From the Release Notes:
The EnterpriseLibraryContainer class no longer exists. You must now explicitly bootstrap the blocks in your code now that Enterprise Library no longer relies on Unity to perform this function.
This applies to the ContainerModel as well since a container is no longer used.

There are Hands-On Labs for Microsoft Enterprise Library 6 but I don't think anything specifically for extensibility. One approach is to take a look at the EntLib source code to model the classes. The core interfaces haven't changed but configuration classes are different (e.g. GetRegistrations is no longer used).

What are you trying to achieve?

Randy Levy
Enterprise Library support engineer
Support How-to
Dec 12, 2014 at 1:22 PM
Hi Randy

I've created a custom trace listener to log errors to a WCF service.
It's works already, but I'm trying to make it work like this:
 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
            <add listenerDataType="MyLib.MyWcfTraceListenerData, Version=, Culture=neutral, PublicKeyToken=null"
                property1="value1" property2="value2" type="MyLib.MyWcfTraceListener, Version=, Culture=neutral, PublicKeyToken=null"
                name="WcfTraceListener" formatter="Text Formatter" />
Currently the values for property1 and property2 are being stored as <appSettings>.
The class MyWcfLoggerData extends TraceListenerData and overrides the function GetCreationExpression as follows:
  protected override Expression<Func<TraceListener>> GetCreationExpression()
            return () => new MyWcfTraceListener(Container.ResolvedIfNotNull<ILogFormatter>(Formatter),
Looks like the lab example relies to some DI container to obtain an instance of the formatter.
How can I replace the Container.ResolvedIfNotNull call?
Dec 15, 2014 at 2:26 AM
The approach in version 6 is simplified because instead of overriding GetCreationExpression and creating an Expression<Func<TraceListener>> you override TraceListenerData.CoreBuildTraceListener() and just return the actual TraceListener instance. For example:
protected override TraceListener CoreBuildTraceListener(LoggingSettings settings)
    ILogFormatter formatter = this.BuildFormatterSafe(settings, this.Formatter);

    return new MyWcfTraceListener(formatter,

I would recommend looking at the sample trace listeners on the Enterprise Library V6 Sample Projects page (Custom Database Trace Listener Sample and Rolling XML Trace Listener Sample & (Rolling) Flat File Trace Listeners). The samples contain full integration examples.

Randy Levy
Enterprise Library support engineer
Support How-to
Marked as answer by betodelle on 12/15/2014 at 4:30 AM
Dec 15, 2014 at 12:32 PM
Now It's working as expected.
Thanks Randy.