This documentation is archived and is not being maintained.

XmlMessageFormatter.TargetTypeNames Property

Specifies the set of possible types that will be deserialized by the formatter from the message provided.

[Visual Basic]
Public Property TargetTypeNames As String ()
public string[] TargetTypeNames {get; set;}
public: __property String* get_TargetTypeNames();
public: __property void set_TargetTypeNames(String* __gc[]);
public function get TargetTypeNames() : String[];
public function set TargetTypeNames(String[]);

Property Value

An array of type String that specifies the types of objects to deserialize from the message body when reading the message.


Exception Type Condition
ArgumentNullException The TargetTypeNames property is a null reference (Nothing in Visual Basic).


Both the TargetTypeNames and TargetTypes properties tell the formatter what schemas to attempt to match when deserializing a message. This allows the formatter to interpret the message body.

The instance serialized in the message body must comply with one of the schemas represented in the type array. When you read the message using the Receive method, the method creates object of the type that corresponds to the schema identied and reads the message body into it.

Only one of the two properties needs to be set when reading from the queue, but you can set both. The set of types is the combined set from the two properties. The decision of which property to use is specific to your application. If the message body contains a type whose schema does not match any of the types in the array for either property, an exception will be thrown when the message is read.

TargetTypeNames requires every entry to be fully qualified, specifying its assembly name. Further, when working with multiple concurrent versions, the version number must also be appended to the target type name as well.

Note   The target types are only required when reading from the queue. The TargetTypeNames and TargetTypes properties do not need to be set to write to the queue.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

XmlMessageFormatter Class | XmlMessageFormatter Members | System.Messaging Namespace | TargetTypes | CanRead | XmlMessageFormatter