Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Dispose member already defined?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ole - 25 Oct 2007 18:13 GMT
I have created an user control (that inherits UserControl) in which I have
defined an override on the Dispose member like this:

protected override void Dispose( bool disposing )
{
try
{
      blackPen.Dispose();
      redPen.Dispose();
      bluePen.Dispose();
}
catch
{ }
}

But the compiler complains with the error message:
"The Control" already defines a member called 'Dispose' with the same
parameter

Any clue what could be wrong?

Thanks
Ole
Nicholas Paldino [.NET/C# MVP] - 25 Oct 2007 18:30 GMT
Ole,

   Well, the compiler error is pretty explicit.  Did you look in the
designer generated code?  My guess is that is where you will find the method
that the designer created.

   If you are storing these pens, and want to get rid of them when
disposing, then I would modify that method to dispose of your pens.

   If modifying designer-generated code doesn't sound like a great idea to
you, you could create a class which derives from Component, and then add
that to your form.  Then, on that component, you would have an Add method
which would take an IDisposable reference, and in that component's dispose
method, you would cycle through and call Dispose on whatever was added
(which you have to keep a list of internally, of course).

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I have created an user control (that inherits UserControl) in which I have
>defined an override on the Dispose member like this:
[quoted text clipped - 19 lines]
> Thanks
> Ole
Ole - 25 Oct 2007 19:04 GMT
Hi Nicholas,

You're absolutely right - why didn't I figure that out - well thanks for
your help!

BR
Ole

> Ole,
>
[quoted text clipped - 35 lines]
>> Thanks
>> Ole

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.