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 client applications forms part of your responsibilities at Domain.com. You are currently creating a message queue programmatically. This message queue will be accessed by two applications. Each message represents an instance of a public class named OrderInfo. The OrderInfo class does not derive from ServicedComponent, and it does not implement any interfaces. You need to ensure that the state of the class is preserved when a message is sent to and received from the message queue. This state of the class would include the values of private members. The message receiving application understands only the basic .NET Framework classes, and the OrderInfo class. To this end you need to specify the formatter that will be used to serialize and deserialize messages.
What should you do?
A.
You need to specify and instance of the custom formatter class.
B.
You need to specify and instance of the ActiveXMessageFormatter.
C.
You need to specify and instance of the BinaryMessageFormatter class.
D.
You need to specify and instance of the XmlMessageFormatter class.
Explanation:
The BinaryMessageFormatter class can be used to serialize and deserialize all members of a class, including private members.
Incorrect answers:
A: The custom formatter class should only be used if none of the default formatter classes are acceptable. In this case the receiving application understands only the basic .NET Framework classes and the OrderInfo class. The OrderInfo class cannot by used as the custom formatter because it does not implement the IMessageFormatter interface with is a requirement when implementing custom formatters.
B: The ActiveXMessageFormatter is used to serialize COM and COM+ components. In this case, the class that the message represents does not derive from ServicedComponents and only managed classed derived from ServicesComponents are also COM+ components.
D: An XmlMessageFormatter class cannot be used to serialize and deserialize private members of a class.