why do I need System.ComponentModel.Component?
Anytime I create a ClassLibrary solution in VB.NET, the class created by the
IDE defaults to inherit System.ComponentModel.Component. Why is this?
If every class must inherit System.ComponentModel.Component and each class
is limited to just one base class, how am I supposed to code anything? If
System.ComponentModel.Component does not have to be implemented in every
class, then why does VB.NET implement it in the default class it creates?
Re: why do I need System.ComponentModel.Component?
> If every class must inherit System.ComponentModel.Component and each
> class is limited to just one base class, how am I supposed to code
> anything? If System.ComponentModel.Component does not have to be
> implemented in every class, then why does VB.NET implement it in the
> default class it creates?
It implements it by default, because when creating a class library project,
it is assumed you want to have at least one Component as the root of that
A Component is "designable", just like a UserControl, and provides the base
implementation for integrating with IDEs. IOW, you can add Components to
toolboxes, drag-&-drop them onto designer palettes, and set properties using
the property sheet.
However, deriving from Component is by no means required. You can simply
delete the "Inherits Component" bit, and derive from Object or anything else
if you want. Alternatively just create a blank project (can't remember if
one exists on the new project dialog) and add standard classes to it, or
just delete the default Component class that is created.
Essentially there are only 2 types of project: An executable (exe) which
contains a Main method to start it off, and a library (dll) which doesn't
contain a Main method.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center