C# EnterpriseLibrary Logger错误:从未同步的代码块调用了对象同步方法
我在使用MS Enterprise Library Logger登录时开始出现此错误 日志机制将日志条目排队,然后使用计时器每10秒刷新一次条目 它在一段时间内工作正常,但今天开始出现以下错误: 代码行:C# EnterpriseLibrary Logger错误:从未同步的代码块调用了对象同步方法,c#,logging,asynchronous,unity-container,enterprise-library,C#,Logging,Asynchronous,Unity Container,Enterprise Library,我在使用MS Enterprise Library Logger登录时开始出现此错误 日志机制将日志条目排队,然后使用计时器每10秒刷新一次条目 它在一段时间内工作正常,但今天开始出现以下错误: 代码行: Logger.Write(list[i]); 错误消息: Object synchronization method was called from an unsynchronized block of code. 堆栈跟踪: at Microsoft.Practices.Unity.Sy
Logger.Write(list[i]);
错误消息:
Object synchronization method was called from an unsynchronized block of code.
堆栈跟踪:
at Microsoft.Practices.Unity.SynchronizedLifetimeManager.TryExit()
整个计时器elsapsed事件处理程序:
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
}
}
private void timerecursed(对象发送方,ElapsedEventArgs e)
{
//快速锁定和释放队列-写入中间列表。
var list=新列表();
锁(LogEntryQueueLock)
{
while(true)
{
如果(_logEntryQueue.Count这似乎是一个现有问题:
好消息是,这应该通过版本2.1.505.2来解决,您可以从以下网址获得: