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.
The development and deployment of Microsoft.NET Remoting components forms part of your responsibilities at Domain.com. You are busy developing a Microsoft.NET Remoting component that will allow messages to be sent between client applications. To this end you are creating an event named MessageReceived. Message Received is configured to accept two parameters:
1. An Object instance that represents the object that raised the event.
2. A MessageReceivedEventArgs instance that will contain the data about the message that was sent.
You need to enable the client applications to receive details about a message that was sent. You thus need to code the MessageReceivedEventArgs class accordingly.
What should you do?
A.
The MessageReceivedEventArgs class must be derived from the ServicedComponent.
B.
The MessageReceivedEventArgs class must be derived from the MarshalByRefObject.
C.
You should apply the Serializable attribute to the MessageReceivedEventArgs class.
D.
You should apply the NonSerializable attribute to each of the MessageReceivedEventArgs class members.
Explanation:
When you apply the Serializable attribute to the MessageReceivedEventArgs class, it will configure the marshal-by-value type. This type can be created on a remote server, serialized, and then transported across the remote boundaries to a remote client.
Incorrect answers:
A: The MessageReceivedEventArgs class should not be derived from the ServicedComponent as ServicedComponent derives from MarshalByRefObject and as such are executed at the server only.
B: The MessageReceivedEventArgs class should not be derived from the MarshalByRefObject as this will configure the class as a marshal by reference type. And these types are executed at the server only.
D: The NonSerializable attribute should not be applied to each member of the MessageReceivedEventArgs class as this will prevent the message details from being serialized.