Using Logging block within DLL

Topics: Logging Application Block
May 25, 2010 at 8:46 PM

I was able to use Logging Appication block within an NUnit test and it works fine. However, when I start using the Logging Application block from within a dll, I get the following error with Enterprise library 4.1

System.Configuration.ConfigurationErrorsException : The configuration section for Logging cannot be found in the configuration source.

and the following error from within Enterprise library 5.0

Microsoft.Practices.ServiceLocation.ActivationException : Activation error occured while trying to get instance of type LogWriter, key ""
  ----> Microsoft.Practices.Unity.ResolutionFailedException : Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type LogWriter cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

   Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,(none)

   ----> System.InvalidOperationException : The type LogWriter cannot be constructed. You must configure the container to supply this value

Basically, since App.config file cannot be included in dlls, I was wondering on how to specify the configuration in the dll.

I would like the applications to use this dll directly to log using the Library application block.

Thanks in advance.

May 26, 2010 at 1:16 AM

I posted my answer to your question in the other thread.  All possible approaches can be found in Tom Hollander's blog.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com