3

I started getting this error when logging using the MS Enterprise Library Logger.

The logging mechanism works my queuing the log entries and then using the timer to flush the entries every 10 seconds.

It was working fine for a while, but today this error started to appear:

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()

Entire timer elsapsed event handler:

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
            }

}

Many thanks for any suggestions!

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

4

1 に答える 1

3

これは既存の問題のようです:http://unity.codeplex.com/workitem/7206

幸いなことに、これはバージョン2.1.505.2で解決する必要があります。バージョン2.1.505.2は、http://nuget.org/packages/Unity/2.1.505.2で入手でき ます

于 2013-01-22T05:32:24.110 に答える