This documentation is archived and is not being maintained.

NetDataContractSerializer.ReadObject Method (XmlReader, Boolean)

Reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object; also checks whether the object data conforms to the name and namespace used to create the serializer.

Namespace: System.Runtime.Serialization
Assembly: System.Runtime.Serialization (in system.runtime.serialization.dll)

public override Object ReadObject (
	XmlReader reader,
	bool verifyObjectName
public Object ReadObject (
	XmlReader reader, 
	boolean verifyObjectName
public override function ReadObject (
	reader : XmlReader, 
	verifyObjectName : boolean
) : Object
Not applicable.



The XmlReader used to read the XML stream or document.


true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace used to construct the serializer; false to skip the verification.

Return Value

The deserialized object.

Exception typeCondition


the reader is set to a null reference (Nothing in Visual Basic).

The verifyObjectName parameter determines whether it can read an object by examining the name and namespace of the XML element the reader is positioned at, and comparing the values to expected name and namespace. The expected name and namespace can be set with the following: the data contract name and namespace of the type passed into the constructor, or the rootName and rootNamespace values passed into the constructor (if present).

You can set the rootName and rootNamespace in the following constructors: NetDataContractSerializer(String,String), NetDataContractSerializer(XmlDictionaryString,XmlDictionaryString), and NetDataContractSerializer(XmlDictionaryString,XmlDictionaryString,StreamingContext,Int32,Boolean,FormatterAssemblyStyle,ISurrogateSelector).

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0