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]
-
mv*@spam.guard.caspershouse.com
"zlf" <zl***@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
Thank you.
I tell show this to designes and force them to change the design:)
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
дÈëÏûÏ¢ÐÂÎÅ:er**************@TK2MSFTNGP02.phx.gbl ... 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]
- mv*@spam.guard.caspershouse.com
"zlf" <zl***@hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP03.phx.gbl...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.ServicedComponentExcepti on:
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