473,498 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Classes derived from ServicedComponent do not support constructors with arguments?

zlf
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
Jun 2 '06 #1
3 3410
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

Jun 2 '06 #2
zlf
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


Jun 2 '06 #3
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



Jun 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4589
by: Xavier | last post by:
Hi, I have a question, in a "dreaded diamond" situation, regarding the following code: ---- Begin code #include <iostream> using namespace std;
5
14405
by: kuvpatel | last post by:
Hi I want to refer a class called LogEvent, and use one of its methods called WriteMessage without actually having to create an instance of Logevent. I have tried using the word sealed with...
4
12857
by: Néstor Marcel Sánchez Ahumada | last post by:
In a method declaration the 'sealed' keyword must be used with the 'override' keyword to avoid further overriding. Thus it can't be used in base classes. Why? This would be a good enhancement for...
34
3656
by: Asfand Yar Qazi | last post by:
Hi, I'm creating a library where several classes are intertwined rather tightly. I'm thinking of making them all use pimpls, so that these circular dependancies can be avoided easily, and I'm...
6
2917
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
4
1846
by: Eric | last post by:
I was wondering what people thought about the information found at: http://g.oswego.edu/dl/mood/C++AsIDL.html Specifically, I am interested in the following recommendation: ---- Since...
26
5333
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
17
3510
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
7
3105
by: ademirzanetti | last post by:
Hi there !!! I would like to listen your opinions about inherit from a STL class like list. For example, do you think it is a good approach if I inherit from list to create something like...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.