I use CompactFramework 2.0.
The code generated by Designer does not invoke
InputPanel.Dispose when form is disposing. And
I cannot understand how it can work without
manual fixing.
Example:
using (Form2 form = new Form2())
{
form.ShowDialog();
}
// Form2 instance is disposed, but inputPanel1 is not
Now if I show or hide SIP in other forms, Form2.inputPanel1
will also get event EnabledChanged and it will lead to an error(
because the form it belongs is already disposed)
private void inputPanel1_EnabledChanged(object sender, EventArgs e)
{
//this code throw exception because form instance is disposed
this.Text = "Form2 " + inputPanel1.Enabled.ToString();
}
So, to fix the problem I need manually fix Designer code
protected override void Dispose(bool disposing)
{
// Bug fix
if (disposing)
{
inputPanel1.Dispose();
}
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Is it a bug?
Thanks,
Tom.
<ctacke/> - 23 Jan 2006 12:08 GMT
You're certain Form2 is getting disposed? A Form shown with ShowDialog does
not get disposed when closed - that's by design.
-Chris
>I use CompactFramework 2.0.
>
[quoted text clipped - 42 lines]
> Thanks,
> Tom.
tomj@softhome.net - 23 Jan 2006 15:00 GMT
Form2 instance is disposed.
USING statement help (C# Reference):
Defines a scope, outside of which an object or objects will be
disposed.
Thanks,
Tom.
Simon Hart - 24 Jan 2006 15:28 GMT
Only if you are explicity calling Dispose(true) from within your
implementation of IDisposable's Dispose.
> Form2 instance is disposed.
>
[quoted text clipped - 4 lines]
> Thanks,
> Tom.