Re: Classes derived from ServicedComponent do not support constructors with arguments?



You have to be careful when you design this stuff as well. For example,
if you are going to use transactions, or just in time activation, or object
pooling, you have to be aware that you are not going to necessarily have the
same object every time (object pooling), or, that the state of the object
will be maintained between calls (JIT activation, transactions).

Because of that, in these situations, you can't do this:

MyObject obj = new MyObject();
obj.Initialize("a");
obj.MyMethod("some parameter");

Because in between the call to Initialize and MyMethod, you might have a
different object, or you can't be expected to have retained the state from
one call to the next.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"zlf" <zlfcn@xxxxxxxxxxx> wrote in message
news:OmUAXWkhGHA.1792@xxxxxxxxxxxxxxxxxxxxxxx
Thank you.
I tell show this to designes and force them to change the design:)

"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
дÈëÏûÏ¢ÐÂÎÅ:erPiHSkhGHA.4892@xxxxxxxxxxxxxxxxxxxxxxx
zlf,

You can not construct a serviced component derived class and have a
constructor. The reason for this is that serviced components are meant
to follow the COM+ architecture. This requires interface
implementations, with default, parameterless constructors.

If you want to store the value, expose a method that takes the
parameter and store it.

BTW, the class definition that you have is pretty much worthless. You
need to attribute it correctly in order to get any kind of use out of it.
Additionally, you should really be exposing an interface and implementing
that.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"zlf" <zlfcn@xxxxxxxxxxx> wrote in message
news:OfmcsijhGHA.4080@xxxxxxxxxxxxxxxxxxxxxxx
I am asked to complete a COM+ component, there is a class A derived from
ServicedComponent.
However, when executing [new A("TEST");], exception is thrown.

Messaged:
Unhandled Exception:
System.EnterpriseServices.ServicedComponentException:
Classes derived from ServicedComponent do not support
constructors with arguments


class A:ServicedComponent
{
public A(){};
public A(string name){};
}

new A("TEST");

Please tell me how to make class derived from ServicedComponent support
constructors with arguments.
Thank you.

zlf








.



Relevant Pages

  • Re: Many questions about partially constructed objects !!!???
    ... I agree with your story and design decisions etc. ... problems because constructors are a bad place to have problems as this ... When the constructors fails the whole ... only common framework is delphi's constructor/destructor framework. ...
    (alt.comp.lang.borland-delphi)
  • Re: [Class]Ridiculous question
    ... These schools of thought are not opposite or immiscible but rather complementary and both can be used in the same design. ... aa.setIndexation(sosaRoot2); ... On the other side of the coin there is something called POJO. ... There are also a myriad of configurations available for the average Swing object, which would require a confusing myriad of constructors to support if they went the POJO route, so again Beans win here by virtue of simplicity. ...
    (comp.lang.java.help)
  • Re: Classes derived from ServicedComponent do not support constructors with arguments?
    ... I tell show this to designes and force them to change the design:) ... You can not construct a serviced component derived class and have a ... Classes derived from ServicedComponent do not support constructors ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Classes derived from ServicedComponent do not support constructors with arguments?
    ... You can not construct a serviced component derived class and have a ... Classes derived from ServicedComponent do not support constructors ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Where to put user interface
    ... >constructors to get the data needed to build an object. ... >used to create an object initialized with the arguments from the I/O. ... whole slew of design issues they either may not be ... Comeau C/C++ with Dinkumware's Libraries... ...
    (alt.comp.lang.learn.c-cpp)