In the Writing Components topic of Mr. Grimes' book on Managed C++, he
states that if a component is ultimately derived from either
MarshalByRefObject or MarshalByValueComponent, it should implement a second
constructor which takes an IContainer in order to add itself to a component
container. While I understand that components have containers, I have seen
no documentation regarding a second constructor to a component. Does it
really exist or is this an error in Mr. Grimes' nearly flawless technical
writing. If this second constructor actually exists:

1) What container(s) creates a component calling this second constructor ?
2) Why does MarshalByRefObject or MarshalByValueComponent not have this
second constructor which would automatically add itself to an IContainer
derived object when a derived class calls down to one of these bases in its
constructor ?
3) Where in the MSDN documentation is this second constructor documented ?

Re: Component constructors, is there another one ? by Dmitriy

Dmitriy
Mon Feb 23 03:10:59 CST 2004

Hi Edward,

> 1) What container(s) creates a component calling this second constructor ?

Most likely these are VS .NET designers (WinForms and WebForms)

> 3) Where in the MSDN documentation is this second constructor documented ?

Well, I found it mentioned here:

"Walkthrough: Authoring a Component with Visual C#"

But, indeed, it seems that this constructor is not well explained in the
MSDN. I suppose it is used by the designers (and is automatically added when
you add a new component to your project). Here's an article on CodeProject:

http://www.codeproject.com/dotnet/disposable_components.asp

that can probably shed more light on this topic.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Edward Diener" <eddielee@tropicsoft.com> wrote in message
news:enko7CQ%23DHA.1804@TK2MSFTNGP12.phx.gbl...
> In the Writing Components topic of Mr. Grimes' book on Managed C++, he
> states that if a component is ultimately derived from either
> MarshalByRefObject or MarshalByValueComponent, it should implement a
second
> constructor which takes an IContainer in order to add itself to a
component
> container. While I understand that components have containers, I have seen
> no documentation regarding a second constructor to a component. Does it
> really exist or is this an error in Mr. Grimes' nearly flawless technical
> writing. If this second constructor actually exists:
>
> 1) What container(s) creates a component calling this second constructor ?
> 2) Why does MarshalByRefObject or MarshalByValueComponent not have this
> second constructor which would automatically add itself to an IContainer
> derived object when a derived class calls down to one of these bases in
its
> constructor ?
> 3) Where in the MSDN documentation is this second constructor documented ?
>
>


Re: Component constructors, is there another one ? by Edward

Edward
Mon Feb 23 08:14:20 CST 2004

Dmitriy Lapshin [C# / .NET MVP] wrote:
> Hi Edward,
>
>> 1) What container(s) creates a component calling this second
>> constructor ?
>
> Most likely these are VS .NET designers (WinForms and WebForms)
>
>> 3) Where in the MSDN documentation is this second constructor
>> documented ?
>
> Well, I found it mentioned here:
>
> "Walkthrough: Authoring a Component with Visual C#"
>
> But, indeed, it seems that this constructor is not well explained in
> the MSDN. I suppose it is used by the designers (and is automatically
> added when you add a new component to your project). Here's an
> article on CodeProject:
>
> http://www.codeproject.com/dotnet/disposable_components.asp
>
> that can probably shed more light on this topic.

Thanks for the information. It does seem as if this second constructor
should be documented in MSDN for component developers. Yet when one looks at
System::ComponentModel::Component, there is clearly only a single
constructor mentioned. Does this mean that if I add this constructor for my
component, I still invoke the default constructor for
System::ComponentModel::Component in my base class ?

>
>
> "Edward Diener" <eddielee@tropicsoft.com> wrote in message
> news:enko7CQ%23DHA.1804@TK2MSFTNGP12.phx.gbl...
>> In the Writing Components topic of Mr. Grimes' book on Managed C++,
>> he states that if a component is ultimately derived from either
>> MarshalByRefObject or MarshalByValueComponent, it should implement a
>> second constructor which takes an IContainer in order to add itself
>> to a component container. While I understand that components have
>> containers, I have seen no documentation regarding a second
>> constructor to a component. Does it really exist or is this an error
>> in Mr. Grimes' nearly flawless technical writing. If this second
>> constructor actually exists:
>>
>> 1) What container(s) creates a component calling this second
>> constructor ? 2) Why does MarshalByRefObject or
>> MarshalByValueComponent not have this second constructor which would
>> automatically add itself to an IContainer derived object when a
>> derived class calls down to one of these bases in its constructor ?
>> 3) Where in the MSDN documentation is this second constructor
>> documented ?