XmlMessageFormatter.CanRead(Message) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the formatter can deserialize the message.
public:
virtual bool CanRead(System::Messaging::Message ^ message);
public bool CanRead (System.Messaging.Message message);
abstract member CanRead : System.Messaging.Message -> bool
override this.CanRead : System.Messaging.Message -> bool
Public Function CanRead (message As Message) As Boolean
Parameters
Returns
true
if the XML formatter can deserialize the message; otherwise, false
.
Implements
Exceptions
Neither the TargetTypeNames nor TargetTypes property has been set.
The message
parameter is null
.
Remarks
When CanRead is called, the formatter attempts to determine if the contents of the message are something it can deserialize. The formatter can only deserialize the message if the type in the message body has the same schema as one of the types in the array represented by the TargetTypeNames and TargetTypes properties. CanRead returns false
under the following two circumstances:
The message was not formatted using the XmlMessageFormatter.
The schema of the message body is not among those listed in either the TargetTypeNames or TargetTypes property.
The TargetTypeNames and TargetTypes properties tell the formatter what types of objects it must be able to deserialize. If any type is missing from the list, yet is found within the message, CanRead returns false
.