Code Analysis; CA2000 Question (g__initLocal8)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top