I have COM-Interop enabled C# library (DLL) where I configured App.config to enable enterprise logging. But as soon as my BootStrapper.Run is called from COM dll, I keep getting the below error though logging & common DLLs exist in my bin folder Microsoft.Practices.EnterpriseLibrary.Logging.dll (v6.0.1304.0) Microsoft.Practices.EnterpriseLibrary.Common.dll (v6.0.1304.0)
{"An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
NOTE: If I call BootStrapper.Run() from console (EXE) application, the logger facade initialization is success. But when I call the same from COM-Interop enabled C# DLL, I get the above error.
I get the mentioned exception when trying to initialize LogWriterFactory (3rd line in try block)
public LoggingService()
{
try
{
var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
IConfigurationSource configurationSource = new FileConfigurationSource(appConfig.FilePath);
var logWriterFactory = new LogWriterFactory(configurationSource);
Logger.SetLogWriter(logWriterFactory.Create());
}
catch(Exception exception)
{
Console.Write(exception.Message);
}
}
Am I missing something here?
After running fusion logger I get the below log:
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Logging, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: Microsoft.Practices.EnterpriseLibrary.Logging, Culture=neutral, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token.
=== LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).