can i use enterprise library v2.0 in a class (DLL) project ?

Topics: Enterprise Library Core, Exception Handling Application Block, General discussion, Logging Application Block
Mar 6, 2007 at 7:33 AM
I have read that EL 2.0 configuration (APP.config) has to be hosted in the host application, it is however mentioned here that EL. 2.0 configuration can be read from another source contained within a class library project

my requirement is that i have to create a DLL project and use it as COM registred for use in ASP 3.0 using facade pattern. now i cant host the EL v2.0 in ASP 3.0,and it wont be possible for me to convert the existing app over to .net 2.0 in the given timeframe

I really wanted to use the application exception block for mailing and logging any exceptions that arise in the component. anyone has any ideas on how to do this ?
Mar 6, 2007 at 3:40 PM
Enterprise Library 2.0 / 3.0 Application Blocks look for their configuration in a configuration store that supports IConfigurationSource. You could create your own implementation of IConfigurationSource to save/retrieve configuration settings or use one of the 2 provided by Enterprise Library 2.0:

1) SystemConfigurationSource - Gets configuration information from application's app.config or web.config
2) FileConfigurationSource - Gets configuration information from an external file where you provide the path

In the quickstarts there is also an example of creating your own IConfigurationSource, called SqlConfigurationSource, that gets configuration information from a database.

Tom's example that you refer to above shows one way to use the FileConfigurationSource, but there are others. I talk about it more in depth in the following tutorial:

Enterprise Library 2.0 - From Configuration Block to IConfigurationSource - SystemConfigurationSource - FileConfigurationSource

Probably what you are looking for is a solution where you specify an external configuration file like this for use with the Exception Handling Block:

namespace IConfigurationSourceExample
    class Program
        static void Main(string[] args)
            IConfigurationSource source = new FileConfigurationSource("ExceptionHandling.config");
            catch(Exception ex)
                bool rethrow = ExceptionPolicy.HandleException(ex, "LoggingPolicy", source);
                if (rethrow)

The path using FileConfigurationSource can be a relative path from the root directory of the application or an absolute path specifying exact location. As for specific use of this code with COM, I have never tried it.




David Hayden
Microsoft MVP C#
Mar 7, 2007 at 4:29 AM
Thanx dave, I'll try it out sometime.

I have to use it with COM, so i guess i'lll just use a simple mail component on unhandled exceptions.


Danish Shamim
Aug 19, 2008 at 12:50 PM

If i make changes to the new config file entlib.config at runtime, would it restart my web application ?