XmlObjectSerializer.WriteEndObject Method

Definition

Writes the closing XML element to an XML stream or document.

Overloads

WriteEndObject(XmlWriter)

Writes the end of the object data as a closing XML element to the XML document or stream with an XmlWriter.

WriteEndObject(XmlDictionaryWriter)

Writes the end of the object data as a closing XML element to the XML document or stream with an XmlDictionaryWriter.

Remarks

The WriteStartObject, WriteObjectContent, and WriteEndObject methods must be implemented. The three methods are used in succession to write the complete serialization using the pattern: write start, write content, and write end. Users can insert XML attributes during the writing of the object between the calls to WriteStartObject and WriteEndObject. The three methods are also called by the virtual implementation of the WriteObject method.

WriteEndObject(XmlWriter)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Writes the end of the object data as a closing XML element to the XML document or stream with an XmlWriter.

C#
public virtual void WriteEndObject(System.Xml.XmlWriter writer);

Parameters

writer
XmlWriter

An XmlWriter used to write the XML document or stream.

Exceptions

the type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

there is a problem with the instance being serialized.

the maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

WriteEndObject(XmlDictionaryWriter)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Writes the end of the object data as a closing XML element to the XML document or stream with an XmlDictionaryWriter.

C#
public abstract void WriteEndObject(System.Xml.XmlDictionaryWriter writer);

Parameters

writer
XmlDictionaryWriter

An XmlDictionaryWriter used to write the XML document or stream.

Exceptions

the type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

there is a problem with the instance being serialized.

the maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0