I am trying to using the Logging Application block of Enterprise Library 5.0 to log simple message to the Windows event log on Win XP SP3 system using:
Logge
I realized that I was trying to use Config file from within a DLL which does not work. I should be using FileConfigurationSource instead.
If I use the same App.Config from an application, it worked fine.
I've had the same error when using a separate entlib config file.
In Web.config, enterpriseLibrary.ConfigurationSource pointed to EntLib.config. When I used the EnterpriseLibrary.Config tool to edit EntLib.config to set up the logging database details, it put everything in EntLib.config. I got this error until I moved the connetionStrings section to Web.config.
Reading the other answers to this question, and from my own experiences, in general it seems this error occurs when your application cannot read some required configuration for the Logging application block from a config file.
To add to the scenarios mentioned in previous answers, I've come across this error a couple of times:
1) In a unit test project, where I forgot to add an app.config file at all;
2) In a config file where I deleted a particular listener from the loggingConfiguration section but forgot to remove the name of the listener from the categorySource that referenced it.
I've also seen this error when forgetting to add a reference to the EntLib DLL's.
It is missing DLL; pay attension when you place your DLL's at GAC you may need to add more DLL's to GAC . Common, Data, Logging, Logging.Database and ServiceLocation DLLS make sure they reside together in one directory
I just wanted to add this error may be caused by another configuration issue. Make sure to look at the inner exceptions for this error. In my case it was:
"The type Database cannot be constructed. You must configure the container to supply this value."
To resolve this I had to add a providerName to my database connection string in the web.config. So the final connection string node looked like this:
<add name="DBConn" connectionString="Data Source=ServerName;Initial Catalog=Logging;Persist Security Info=True;integrated security=True;" providerName="System.Data.SqlClient" />