|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Trace.WriteLine(object value) - causes "System.InvalidOperationException: Collection was modified; eTrace.WriteLine(object value): "System.InvalidOperationException: Collection was modified; enumeration operation may not execute." if (Trace.Listeners.Count > 0) { Trace.WriteLine(entry); // line 424 } - Here is the stack trace: ********* Exception details: ********** Unexpected exception. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext() at System.Diagnostics.TraceInternal.WriteLine(Object value) at System.Diagnostics.Trace.WriteLine(Object value) at MyLogger.Write(LogEntry entry) in MyLogger.cs:line 424 - If I where to instead do the following, it would work. So this seems that something in the framework is attempting to modify the Trace.Listeners collection: for (int i = 0; i < Trace.Listeners.Count; i++) { TraceListener traceListener = Trace.Listeners[i]; traceListener.WriteLine(entry); } |
|||||||||||||||||||||||