Activation error occured while trying to get instance of type ExceptionManager, key is killing me!

Topics: Exception Handling Application Block, Logging Application Block
Oct 11, 2010 at 1:38 PM


I'm new to the enterprise library and I am currently trying to integrate the exception and logging blocks into my application but no matter what I do, once the configuration is happy, I get the error:

Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type ExceptionManager 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.ExceptionHandling.ExceptionManager,(none)

{"Activation error occured while trying to get instance of type ExceptionManager, key \"\""}


When it executes the line:

     exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();

Am I missing something fairly fundamental here?

Any pointers would be great or if anyone has a basic example solution of what needs to be set up that would help.



Oct 11, 2010 at 6:27 PM

This is typically caused when the system is using a configuration file different than the one you think it's using. Where (which assembly) is the code calling Entlib, and what config file do you want it to be pulling from?


Oct 12, 2010 at 10:00 AM

Thanks for responding!

You could be right, I have managed to solve my issues and get the project going, here is a list of things I had to correct:

I wanted to use a quick start to get a basic pattern in place an modify. The RC samples library with V5 just wouldn't work for me. I used a sample from 4.1 and had to adapt.

Changes to get working:

  • Remove all traces of EntLib 4.1 from my machine.
  • Add the <unity> configuration block to my config file.
  • ALL type references given in the examples did not work and needed to be fully qualified to work. e.g.:


              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging"


              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"


  • Resolve all configuration issues in the XML (as identifed by the EntLib 5 config editor).

And now the application runs.



Oct 12, 2010 at 4:43 PM

Did you put Entlib in the GAC? That would explain why you needed fully qualified type names everywhere. If not, that's kind of weird.

Also, why did you add a <unity> section? Are you actually using Unity directly somewhere?


Oct 13, 2010 at 8:57 AM


Yes I did put the EntLib into the GAC. After removing V4.1 and placing the library in defined location and referencing in my app., the app still wouldn't start due to unresolved references to the library. I installed the library into the GAC and problem went away. Is placing the library in the GAC thereason why the assembly reference needs to be fully qualified?

This is fine for us as we intend to deploy the application onto a Virtualised Farm and we always install stable 3rd party dlls into the GAC.

I've now removed the unity configuration block from the configuration file and the application starts fine - red herring!

Thanks for your help

Oct 13, 2010 at 5:06 PM
andycurtUK wrote:

 Is placing the library in the GAC thereason why the assembly reference needs to be fully qualified?

Yes. .NET only looks in the GAC for fully assembly-qualified type names.

In general the config tool generates fully qualified names anyway, so it's not usually an issue. Glad you've gotten it working.


Oct 13, 2010 at 6:01 PM


Incidentally, I had this error when trying to set up WCF Exception Shielding with logging.

The cure was to include Microsoft.Practices.EnterpriseLibrary.Validation in the project.  There is (I assume) some kind of internal dependency there
(even though I'm not using the validation block).


Oct 14, 2010 at 8:53 AM


Yes it seems that it's quite easy to confuse the framework in this manner and the reported exceptions are initially rather confusing as to what the root cause is - perhaps one for next version feature list!

Today I had my old friend "Activation error occured while trying to get instance of type ExceptionManager, key ..." return again after adding database logging of exceptions. This truns out to be an issue with the Data framework not being able to find it's configuration if it is installed in the GAC. I cured this problem by setting the "Copy Local" flag on all the Enterprise Library references in my project.

Happy days!