Export (0) Print
Expand All

DataContractResolver.ResolveName Method

.NET Framework 4.6 and 4.5

Override this method to map the specified xsi:type name and namespace to a data contract type during deserialization.

Namespace:  System.Runtime.Serialization
Assemblies:   System.Runtime.Serialization (in System.Runtime.Serialization.dll)
  System.Runtime.Serialization.Xml (in System.Runtime.Serialization.Xml.dll)

public abstract Type ResolveName(
	string typeName,
	string typeNamespace,
	Type declaredType,
	DataContractResolver knownTypeResolver


Type: System.String

The xsi:type name to map.

Type: System.String

The xsi:type namespace to map.

Type: System.Type

The type declared in the data contract.

Type: System.Runtime.Serialization.DataContractResolver

The known type resolver.

Return Value

Type: System.Type
The type the xsi:type name and namespace is mapped to.

If you want to use the known type resolution logic inside your implementation, a reference to it is passed in as the knownTypeResolver parameter.

The following example shows an implementation of the ResolveName method.

// Used at deserialization 
// Allows users to map xsi:type name to any Type  
public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
    XmlDictionaryString tName;
    XmlDictionaryString tNamespace;
    if (dictionary.TryGetValue(typeName, out tName) && dictionary.TryGetValue(typeNamespace, out tNamespace))
        return this.assembly.GetType(tNamespace.Value + "." + tName.Value);
        return null;

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
© 2015 Microsoft