Hi Max,
It seems that you're using VS2005.
In VS2005, the override Dispose(bool) method implementation and Windows
Forms Designer generated code, i.e. the InitializeComponent method are
separated into a designer file.
It is not recommended to change the code in the InitializeComponent method
because the designer would change the code in the method when there's a
change on the form designer.
But it doesn't include the Dispose(bool) method. We could write our own
code in the Dispose(bool) method without any worry about our own code's
being flushed by Windows Forms Designer later.
The Form class has implemented IDisposable interface and define a virtual
method Dispose(bool). The virtual Dispose(bool) method contains the code to
release resources the form is holding, and is called in the
IDisposable.Dispose implementation within the Form class with a parameter
of value true. The destructor of the form will also call the Dispose(bool)
method, but with a parameter of value false. FYI, when the form is closed,
the IDisposable.Dispose() method is called by the form from inside to
release the resource explicitly.
As for the derived Form class, what we need to do is to override the
Dispose(bool) method should to contain extra code to release resources the
derived form class is holding, if there's any.
You could put your code for releasing the managed/native resources in the
existing override Dispose(boo) method in the design file.
Hope I make some clarification.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.