|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Component constructor in .NET 2.0I looked in the documentation for System.ComponentModel.Component's
constructor but I only noticed a constructor taking no parameters. My understanding is that there is a second constructor which takes a System.ComponentModel.IContainer interface object. Has this been the case in previous .NET releases and has this changed with .NET 2.0 ? Edward Diener wrote:
> I looked in the documentation for System.ComponentModel.Component's Ildasm shows only the no-args constructor for V1.1 and V2.0. Why do you > constructor but I only noticed a constructor taking no parameters. My > understanding is that there is a second constructor which takes a > System.ComponentModel.IContainer interface object. Has this been the > case in previous .NET releases and has this changed with .NET 2.0 ? believe there's another constructor? -cd Carl Daniel [VC++ MVP] wrote:
> Edward Diener wrote: If I use VS2005 to generate a component class, it creates both a no >> I looked in the documentation for System.ComponentModel.Component's >> constructor but I only noticed a constructor taking no parameters. My >> understanding is that there is a second constructor which takes a >> System.ComponentModel.IContainer interface object. Has this been the >> case in previous .NET releases and has this changed with .NET 2.0 ? > > Ildasm shows only the no-args constructor for V1.1 and V2.0. Why do you > believe there's another constructor? argument constructor and a constructor which takes a System.ComponentModel.IContainer container interface with the comment "/// /// Required for Windows.Forms Class Composition Designer support ///" This leads me to believe that all component derived classes need to specify this second constructor. As a component developer I have added this second constructor to all my components, with the appropriate logic of adding the component to the container passed in the constructor. Is this necessary ? What is the story with this second constructor ? I could find no documentation regarding it in the VS2005 doc for any .NET component classes. Edward Diener wrote:
Show quote > Carl Daniel [VC++ MVP] wrote: IIUC, it has no function outside the windows forms designer - effectively an >> Edward Diener wrote: >>> I looked in the documentation for System.ComponentModel.Component's >>> constructor but I only noticed a constructor taking no parameters. >>> My understanding is that there is a second constructor which takes a >>> System.ComponentModel.IContainer interface object. Has this been the >>> case in previous .NET releases and has this changed with .NET 2.0 ? >> >> Ildasm shows only the no-args constructor for V1.1 and V2.0. Why do >> you believe there's another constructor? > > If I use VS2005 to generate a component class, it creates both a no > argument constructor and a constructor which takes a > System.ComponentModel.IContainer container interface with the comment > > "/// > /// Required for Windows.Forms Class Composition Designer support > ///" > > This leads me to believe that all component derived classes need to > specify this second constructor. As a component developer I have added > this second constructor to all my components, with the appropriate > logic of adding the component to the container passed in the > constructor. Is this necessary ? What is the story with this second > constructor ? I could find no documentation regarding it in the > VS2005 doc for any .NET component classes. internal implementation detail of the designer that leaks into your code. -cd Carl Daniel [VC++ MVP] wrote:
Show quote > Edward Diener wrote: So you are saying that the windows form designer uses this second >> Carl Daniel [VC++ MVP] wrote: >>> Edward Diener wrote: >>>> I looked in the documentation for System.ComponentModel.Component's >>>> constructor but I only noticed a constructor taking no parameters. >>>> My understanding is that there is a second constructor which takes a >>>> System.ComponentModel.IContainer interface object. Has this been the >>>> case in previous .NET releases and has this changed with .NET 2.0 ? >>> Ildasm shows only the no-args constructor for V1.1 and V2.0. Why do >>> you believe there's another constructor? >> If I use VS2005 to generate a component class, it creates both a no >> argument constructor and a constructor which takes a >> System.ComponentModel.IContainer container interface with the comment >> >> "/// >> /// Required for Windows.Forms Class Composition Designer support >> ///" >> >> This leads me to believe that all component derived classes need to >> specify this second constructor. As a component developer I have added >> this second constructor to all my components, with the appropriate >> logic of adding the component to the container passed in the >> constructor. Is this necessary ? What is the story with this second >> constructor ? I could find no documentation regarding it in the >> VS2005 doc for any .NET component classes. > > IIUC, it has no function outside the windows forms designer - effectively an > internal implementation detail of the designer that leaks into your code. constructor if it is present but uses the normal no-args constructor if it is not ? Still I think it should be documented in the .NET API so that component developers will understand that it is being used by components distributed by Microsoft and that they should use the same technique in order to work well with the windows form designer. |
|||||||||||||||||||||||