<add> of <declaredTypes> Element
Adds a type used by the DataContractSerializer during deserialization. Each declared type includes the known types that will be returned as a field or property of the declared type.
Schema Hierarchy
<system.runtime.serialization>
<dataContractSerializer> of <system.runtime.serialization>
<declaredTypes>
<add> of <declaredTypes> Element
Syntax
<add type="String">
<knownType type="String">
<parameter index="Integer"
type="String" />
</knownType>
</add>
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Attributes
Attribute | Description |
---|---|
type |
Required string attribute. Specifies the type name (including namespace), assembly name, version number, culture, and public key token. |
Child Elements
Element | Description |
---|---|
Specifies the known type for the declared type that is being added. If the declared type is a generic type, then you must also add a parameter element to the <knownType> element to specify which generic parameter is used to return the known type. |
Parent Elements
Element | Description |
---|---|
Contains the types that require known types during deserialization by the DataContractSerializer. |
Remarks
For more information about known types, see Data Contract Known Types and DataContractSerializer.
See the <dataContractSerializer> for an example of using this element.
Note
If you add the Object type as a <declaredType>, a ConfigurationErrorsException is thrown. This is because the Object type cannot be used as a declared type in configuration.
Example
<add type="MyCompany.Library.Shape,
MyAssembly, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=XXXXXX, processorArchitecture=MSIL">
<knownType type="MyCompany.Library.Circle,
MyAssembly, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=XXXXXX,
processorArchitecture=MSIL"/>
</add>
See Also
Reference
<dataContractSerializer>
<add> of <declaredTypes> Element
DataContractSerializer
Other Resources
© 2007 Microsoft Corporation. All rights reserved.
Last Published: 2010-01-05