Code Analysis; CA2000 Question (g__initLocal8)

  • Thread starter Thread starter NvrBst
  • Start date Start date
N

NvrBst

::Error::
CA2000 : Microsoft.Reliability : In method '*', object
'<>g__initLocal8' is not disposed along all exception paths. Call
System.IDisposable.Dispose on object '<>g__initLocal8' before all
references to it are out of scope.

::Code::
using(FolderBrowserDialog sourceFolder = new FolderBrowserDialog()
{ ShowNewFolderButton = false })
if(sourceFolder.ShowDialog(this) == DialogResult.OK)
...;

I'm assuming it is the "ShowNewFolderButton = false" part which is
causing the warning, but, I'm wondering if this really isn't safe?
From the "Show Error Help" window I can understand their example, but,
I don't have to dispose "false" in the above example.

Should I be avoiding this type of syntax when using the "using"
statement? Or is this just an Analysis bug that will probably get
fixed?

I'm using VS2010 targeting .NET Framework 4.0 Client Profile. Please
help me better understand this problem. Thanks.
 
Back
Top