I'm using EntLib 5 logging, validation, and exception handling blocks in a new C# application (also using Prisim). Recently I moved the EntLib configuration out of app.config and into its own "entlib.config" file that will be shared by all users.
All the EntLib features I use have been working until today when I tried to use the Exception block for basic exception logging.
Actually, the exception logging does work if I use the static ExceptionPolicy class -- like so:
ExceptionPolicy.HandleException(ex, "Default Policy");
It also works as expected when using the ServiceLocator to get an ExceptionManager instance:
ExceptionManager exMgr = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
exMgr.HandleException(ex, "Default Policy");
But exceptions don't get logged if I use constructor dependency injection (Unity) to get an ExceptionManager instance.
public class MyClass
private ExceptionManager _exMgr;
public MyClass(ExceptionManager exMgr)
_exMgr = exMgr;
// Later in a catch block
_exMgr.HandleException(ex, "Default Policy");
The class constructor receives an ExecptionManager instance, but when it's used to call HandleException(ex, "Default Policy"), nothing (obvious) happens -- in particular, nothing gets logged. Even though it's using the same external config file
and "Default Policy" as the working cases.
Is there a problem with DI ExceptionManager instances accessing external configuration files?