EnterpriseLibrary Logger error: Object sync method is called from an unsynchronized block of code

I started getting this error when registering with the Logger MS Enterprise Library.

The logging engine works with my log queues and then using a timer to flush the entries every 10 seconds.

It worked fine for a while, but today this error started popping up:

Line of code:

Logger.Write(list[i]);

      

Error message:

Object synchronization method was called from an unsynchronized block of code.

      

Stack trace:

at Microsoft.Practices.Unity.SynchronizedLifetimeManager.TryExit()

      

The whole handler of the processed timer:

private void TimerElapsed(object sender, ElapsedEventArgs e)
{
            // Lock and free free the queue quickly - write to an intermediate list.
            var list = new List<LogEntry>();
            lock (LogEntryQueueLock)
            {
                while (true)
                {
                    if (_logEntryQueue.Count <= 0)
                        break;

                    //dequeue the LogEntry that will be written to the log
                    list.Add(_logEntryQueue.Dequeue());
                }
            }

            // Flush the list in to the log
            for (int i = 0; i < list.Count; i++)
            {
                ProcessEntry(list[i]);  // Strip commas from the string
                Logger.Write(list[i]);  //  <<<== ERRORS HERE
            }

}

      

Thanks a lot for any suggestions!

[EDIT]: I tried to call Logger.Write direclty, without a timer event - same problem ...

+3


source to share


1 answer


This looks like an existing problem: http://unity.codeplex.com/workitem/7206 .



The good news is that this should be allowed with version 2.1.505.2, which you can get from: http://nuget.org/packages/Unity/2.1.505.2 .

+3


source







All Articles