DataContractResolver.ResolveName Method (String, String, Type, DataContractResolver)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.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;

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top