Comments
2 comments
-
Hi,
It sounds like the infamous "event handler" gotcha in .NET. If you hook an event handler to an object, you must remember to dereference it when no longer needed. There could also be unintended references created inside the event handler as in the ASP .NET DataGrid example pointed out here. -
I have not attached any events to the dialog form. All events within the form reference to objects on the form. i.e. change events to several check boxes and text boxes on the dialog form. There is also a finalizer referencing the dialog form as well, which seems odd.
Add comment
Please sign in to leave a comment.
Going thru my code, I only reference the form once in the code segement below. I have verified that code execution runs all of this code and that the Dispose method is called on the form. I can find no other references to this form and can not fathom how in blue blazes can this be reported as a leak.
using (GaugeIndicatorEditorForm form = new GaugeIndicatorEditorForm(copy)) {
if (form.ShowDialog() == DialogResult.OK) {
gauge.GaugeContainer = GaugeContainer;
EditorUtil.HostComponentChanged(context, gauge.GaugeContainer);
if (preview != null) {
preview.DundasRenderDundas(gauge.GaugeContainer, false);
}
}
}
Cut and paste doesn't work for code apparently, so I had to clean it up by hand, hopefully I didn't delete an paren or semi colon by accident. Either way, with code this fricken simple, I just can't figure out why it is being reported as a leak... The parent class of this code is a UITypeEditor and it gets called from the MS property grid.