CA2000 Dispose objects before losing scope
In method FormMain.barButtonItem1_ItemClick(object, ItemClickEventArgs)
Call System.IDisposable.Dispose on object 'frm' before all references to it are out of scope. Winpro FormMain.cs 32
Method :
private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
{
FormCustomerList frm = new FormCustomerList();
frm.MdiParent = this;
frm.Show();
}
This is not a serious problem, but why is this fired?
I can't use finally frm.Dispose()
or using()
because form will not be shown.
I have also tried to handle form closing and then dispose but violation is always here.