Logging to Database Sink with Enterprise Library gives runtime err

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple test app to log to a database.

All I have is

try
{
LogEntry log = new LogEntry();
log.Message = "Testing this logging block";
Logger.Write(log);
}
catch (Exception ex)
{
Debug.WriteLine (ex.Message );
Debug.WriteLine (ex.StackTrace);

}

The XML file seems to be validated by the Ent. library Config. and the Quick
Start functions properly.

The error and stack:

File or assembly name
Microsoft.Practices.EnterpriseLibrary.Logging.Sinks.Database, or one of its
dependencies, was not found.
at System.Type.GetType(String typeName, Boolean throwOnError)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.RuntimeConfigurationView.CollectTypes(XmlIncludeTypeDataCollection xmlIncludeTypes)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.RuntimeConfigurationView.GetXmlIncludeTypes(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.Transformer.XmlSerializerTransformer.Initialize(ConfigurationView configurationView)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ProviderFactory.InitializeConfigurationProvider(String providerName, IConfigurationProvider provider)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.TransformerFactory.InitializeConfigurationProvider(String sectionName, IConfigurationProvider provider)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ProviderFactory.InitializeObject(String providerName, Object createdObject)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ProviderFactory.CreateObject(String providerName, Type type)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationFactory.CreateInstance(String configurationName)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.TransformerFactory.Create(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationBuilder.CreateTransformer(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationBuilder.ReadConfiguration(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationContext.GetConfiguration(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Logging.LoggingConfigurationView.GetDistributorSettings()
at
Microsoft.Practices.EnterpriseLibrary.Logging.LoggingConfigurationView.GetDefaultCategoryData()
at
Microsoft.Practices.EnterpriseLibrary.Logging.Distributor.LogDistributor.GetCategory(LogEntry log)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Distributor.LogDistributor.ProcessLog(LogEntry log)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Distributor.InProcLogDistributionStrategy.SendLog(LogEntry logEntry)
at
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.SendMessage(LogEntry
logEntry)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.Write(LogEntry
log)
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(LogEntry log)
at TestLoggin.Form1.button1_Click(Object sender, EventArgs e) in
c:\visual studio projects\testloggin\form1.cs:line 151
 
I found this is because EL uses reflection (late binding) to get to the
database sink. That dll is not found. Creating a reference to
Microsoft.Practices.EnterpriseLibrary.Logging.Sinks.Database.dll fixes
this problem.
 
Back
Top