CA2000 : DisposeObjectsBeforeLosingScope in Log.cs - TextWriterTraceListener


Log.AddTraceListener() is not paired up with a remove method.


wrote Jun 25, 2007 at 7:37 PM

Description: CA2000 : Microsoft.Reliability : Modify Log.AddTraceListener():Void to dispose temporary resource of type 'TextWriterTraceListener' for all code paths.
File: C:\Documents and Settings\msmithlo\My Documents\personal\VS2005 Projects\EFSAssistant\EFSAssistant\Log.cs
Line: 142
Project: EFSAssistant

MikeSL wrote Jun 28, 2007 at 12:52 AM

There appears to be no Log.RemoveTraceListener() method available, so that the TraceListener will NEVER be disposed. While I don't know whether there is a specific instability case here, this is certainly a significant opportunity for resources to be poorly managed.

At minimum, a RemoveTraceListener() method should be added to the EFSAssistant.Log class, and this method should be called at the equivalent step to whatever this project has to a Form_Unload() event.

wrote Jun 28, 2007 at 12:58 AM

wrote Feb 13, 2013 at 7:48 PM