You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. Domain.com operates as an Internet Auctioneer. The development and deployment of Microsoft.NET Remoting components forms part of your responsibilities at Domain.com. You have been instructed to develop an OrderProcessor class that is responsible for charging a customer’s credit card, notifying the shipping department of the particular product that must be shipped, as well as updating the product inventory database. A COM+ application will be hosting the OrderProcessor class. To this end you need to create the class definition.
What should you do? (Choose the appropriate code segment.)
A.
public class OrderProcessor : WebService {}
B.
public class OrderProcessor : ServicedComponent {}
C.
public class OrderProcessor : MarshalByRefObject {}
D.
public class OrderProcessor : MarshalByValueComponent {}
Explanation:
It is stated in the question that a COM+ application is hosting the class and thus the class must derive either directly of indirectly from the ServicedComponent. The ServicedComponent provides the database for all classes that need to make use of COM+ services. The OrderProcessor class should be derived from ServicedComponent.
Incorrect answers:
A: The OrderProcessor class should not be derived from WebService. This class provides a base class for Microsoft ASP.Net Web services which allows you to access Session and application instances directly.
C: The OrderProcessor class should not be derived from MarshalByRefObject because those types are those that cannot be serialized across an application domain and whose methods must execute remotely. ServicedComponent derives directly from MarshalByRefObject.
D: The OrderProcessor class should not be derived from the MarshalByValueComponent. This class represents marshal-by-value types that can be serialized across an application and whose methods can execute locally.