Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ISerializable::GetObjectData Method (SerializationInfo^, StreamingContext)

 

Populates a SerializationInfo with the data needed to serialize the target object.

Namespace:   System.Runtime.Serialization
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
void GetObjectData(
	SerializationInfo^ info,
	StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization::SerializationInfo^

The SerializationInfo to populate with data.

context
Type: System.Runtime.Serialization::StreamingContext

The destination (see StreamingContext) for this serialization.

Exception Condition
SecurityException

The caller does not have the required permission.

Any objects that are included in the SerializationInfo are automatically tracked and serialized by the formatter.

Code that calls GetObjectData requires the SecurityPermission for providing serialization services. Associated enumeration: SecurityPermissionFlag::SerializationFormatter.

System_CAPS_noteNote

It is not guaranteed that this method will be called only once per object instance during serialization. Therefore, the method should be implemented in such a way that its behavior will be the same regardless of the number of times it is called.

The following example uses the GetObjectData method to set alternate values for a serialized object. The code uses the AddValue method of the SerializationInfo class to store the alternate values when the object is serialized. Conversely, when the constructor of the Person class is called during deserialization, the alternatve values are retrieved using the GetValue method and reassigned to the object's fields.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft