Question

I want to use EnterpriseLibrary 5.0 dlls for logging in my project. For this I have added these dll to my references:

Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Data
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Logging.Database

And then I write this:

using Microsoft.Practices.EnterpriseLibrary.Data; 
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; 
using Microsoft.Practices.EnterpriseLibrary.Logging;

And then I wrote:

LogEntry logEntry = new LogEntry();
logEntry.Message = "Message";
Logger.Write(logEntry);

But when my code executed, I get this exception at the last line:

Activation error occured while trying to get instance of type LogWriter, key ""

that has this InnerException:

Resolution of the dependency failed, type = \"Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter\", name = \"(none)\".\r\nException occurred while: Calling constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener(System.String fileName, System.String header, System.String footer, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter).\r\nException is: IOException - The device is not ready.\r\n\r\n-----------------------------------------------\r\nAt the time of the exception, the container was:\r\n\r\n Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.default (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none))\r\n Resolving parameter \"structureHolder\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator)\r\n Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.default (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, (none))\r\n Resolving parameter \"traceSources\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters, System.Collections.Generic.IEnumerable1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategory, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonation)\r\n Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,Trace\r\n
Resolving parameter \"traceListeners\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name, System.Collections.Generic.IEnumerable
1[[System.Diagnostics.TraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider)\r\n Resolving Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,Flat FileTrace Listener (mapped from System.Diagnostics.TraceListener, Flat FileTrace Listener)\r\n Resolving parameter \"wrappedTraceListener\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener wrappedTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator coordinator)\r\n Resolving Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,Flat FileTrace Listener‌implementation (mapped from System.Diagnostics.TraceListener, Flat FileTrace Listener‌implementation)\r\n Calling constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener(System.String fileName, System.String header, System.String footer, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter)

And it has this InnerException:

The device is not ready.

How to I can resolve this error?

Was it helpful?

Solution 2

This error was from app.config file. I'd use a same app.config file that has some error. When I used an app.config that creates with EntLib application, My error resolved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top