PC Review


Reply
Thread Tools Rate Thread

C# and COM+ Constuct

 
 
=?Utf-8?B?bXN1aw==?=
Guest
Posts: n/a
 
      12th Jan 2005
All,

I am trying to use the COM+ constructor string as follows:

[ConstructionEnabled (true)]
public sealed class xxxx: ServicedComponent
{

public override void Construct(string constructString)
{

}
{

But when I build the project I get the following error:

C:\xxx.cs(33): xxxxxx.Construct(string)': cannot change access modifiers
when overriding 'protected' inherited member
'System.EnterpriseServices.ServicedComponent.Construct(string)'

What am I doing wrong?

Thanks
Msuk



 
Reply With Quote
 
 
 
 
Ollie Riches
Guest
Posts: n/a
 
      12th Jan 2005
The 'Construct' method is defined as 'protected' in the ServicedComponent
class you can't change the access modifier in your derived class - this is
what the compiler error says...

You can't call this method externally from the class....

HTH

Ollie Riches

"msuk" <(E-Mail Removed)> wrote in message
news:3ECC9630-DCD1-4F12-89C3-(E-Mail Removed)...
> All,
>
> I am trying to use the COM+ constructor string as follows:
>
> [ConstructionEnabled (true)]
> public sealed class xxxx: ServicedComponent
> {
>
> public override void Construct(string constructString)
> {
>
> }
> {
>
> But when I build the project I get the following error:
>
> C:\xxx.cs(33): xxxxxx.Construct(string)': cannot change access modifiers
> when overriding 'protected' inherited member
> 'System.EnterpriseServices.ServicedComponent.Construct(string)'
>
> What am I doing wrong?
>
> Thanks
> Msuk
>
>
>



 
Reply With Quote
 
=?Utf-8?B?bXN1aw==?=
Guest
Posts: n/a
 
      12th Jan 2005
Hi,

All the examples show that you can have it as a public method e.g

http://www.ondotnet.com/pub/a/dotnet...t_ch10/?page=6

What should it be?

Thanks
Msuk

"Ollie Riches" wrote:

> The 'Construct' method is defined as 'protected' in the ServicedComponent
> class you can't change the access modifier in your derived class - this is
> what the compiler error says...
>
> You can't call this method externally from the class....
>
> HTH
>
> Ollie Riches
>
> "msuk" <(E-Mail Removed)> wrote in message
> news:3ECC9630-DCD1-4F12-89C3-(E-Mail Removed)...
> > All,
> >
> > I am trying to use the COM+ constructor string as follows:
> >
> > [ConstructionEnabled (true)]
> > public sealed class xxxx: ServicedComponent
> > {
> >
> > public override void Construct(string constructString)
> > {
> >
> > }
> > {
> >
> > But when I build the project I get the following error:
> >
> > C:\xxx.cs(33): xxxxxx.Construct(string)': cannot change access modifiers
> > when overriding 'protected' inherited member
> > 'System.EnterpriseServices.ServicedComponent.Construct(string)'
> >
> > What am I doing wrong?
> >
> > Thanks
> > Msuk
> >
> >
> >

>
>
>

 
Reply With Quote
 
Richard Blewett [DevelopMentor]
Guest
Posts: n/a
 
      12th Jan 2005
IIRC IObjectConstruct (the COM+ construction interface) has the signature

IObjectConstruct
{
HRESULT Construct(IDispatch* pCtorObj);
}

This is obviously not the same signature as the overridable Construct method from ServiceComponent. So ServicedComponent implements the interface and then it's implementation of IObjectConstruct::Construct calls a protected virtual Construct method which you can override. Thats why the Construct method you override is protected rather than public

Regards]

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

The 'Construct' method is defined as 'protected' in the ServicedComponent
class you can't change the access modifier in your derived class - this is
what the compiler error says...

You can't call this method externally from the class....

HTH

Ollie Riches

"msuk" <(E-Mail Removed)> wrote in message
news:3ECC9630-DCD1-4F12-89C3-(E-Mail Removed)...
> All,
>
> I am trying to use the COM+ constructor string as follows:
>
> [ConstructionEnabled (true)]
> public sealed class xxxx: ServicedComponent
> {
>
> public override void Construct(string constructString)
> {
>
> }
> {
>
> But when I build the project I get the following error:
>
> C:\xxx.cs(33): xxxxxx.Construct(string)': cannot change access modifiers
> when overriding 'protected' inherited member
> 'System.EnterpriseServices.ServicedComponent.Construct(string)'
>
> What am I doing wrong?
>
> Thanks
> Msuk


 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      12th Jan 2005
You can't change the access modifier (he, but that's what the compiler
say's..;-).

Change your method definition to:

protected override void Construct(string s) {
..

}

And don't forget that passing a string is done through the
ConstructionEnabledAttribute.

[ConstructionEnabled(Enabled=true, Default="Test string")]


Willy.

"msuk" <(E-Mail Removed)> wrote in message
news:3ECC9630-DCD1-4F12-89C3-(E-Mail Removed)...
> All,
>
> I am trying to use the COM+ constructor string as follows:
>
> [ConstructionEnabled (true)]
> public sealed class xxxx: ServicedComponent
> {
>
> public override void Construct(string constructString)
> {
>
> }
> {
>
> But when I build the project I get the following error:
>
> C:\xxx.cs(33): xxxxxx.Construct(string)': cannot change access modifiers
> when overriding 'protected' inherited member
> 'System.EnterpriseServices.ServicedComponent.Construct(string)'
>
> What am I doing wrong?
>
> Thanks
> Msuk
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:20 AM.