XmlMessageFormatter.TargetTypeNames 屬性


指定可能型別的設定,格式子會從所提供的訊息還原序列化這些型別。Specifies the set of possible types that will be deserialized by the formatter from the message provided.

 property cli::array <System::String ^> ^ TargetTypeNames { cli::array <System::String ^> ^ get(); void set(cli::array <System::String ^> ^ value); };
public string[] TargetTypeNames { get; set; }
member this.TargetTypeNames : string[] with get, set
Public Property TargetTypeNames As String()



String 型別的陣列,讀取訊息時,指定要從訊息主體還原序列化的物件型別。An array of type String that specifies the types of objects to deserialize from the message body when reading the message.



TargetTypeNames 屬性為 nullThe TargetTypeNames property is null.


TargetTypeNames和屬性都會 TargetTypes 告知格式器在還原序列化訊息時,要嘗試比對的架構。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. 當您使用方法讀取訊息時 Receive ,方法會建立對應至所識別架構之類型的物件,並將訊息本文讀入其中。When you read the message using the Receive method, the method creates an object of the type that corresponds to the schema identified 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 要求每個專案都必須是完整的,並指定其元件名稱。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.

只有在從佇列讀取時,才需要目標型別。The target types are only required when reading from the queue. TargetTypeNamesTargetTypes 屬性不需要設定為寫入佇列。The TargetTypeNames and TargetTypes properties do not need to be set to write to the queue.