ObjectManager.RegisterObject Method (Object, Int64, SerializationInfo, Int64, MemberInfo, Int32[])

 

Registers a member of an array contained in an object while it is deserialized, associating it with objectID, and recording the SerializationInfo.

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

[SecurityCriticalAttribute]
public void RegisterObject(
	object obj,
	long objectID,
	SerializationInfo info,
	long idOfContainingObj,
	MemberInfo member,
	int[] arrayIndex
)

Parameters

obj
Type: System.Object

The object to register.

objectID
Type: System.Int64

The ID of the object to register.

info
Type: System.Runtime.Serialization.SerializationInfo

The SerializationInfo used if obj implements ISerializable or has a ISerializationSurrogate. info will be completed with any required fixup information and then passed to the required object when that object is completed.

idOfContainingObj
Type: System.Int64

The ID of the object that contains obj. This parameter is required only if obj is a value type.

member
Type: System.Reflection.MemberInfo

The field in the containing object where obj exists. This parameter has meaning only if obj is a value type.

arrayIndex
Type: System.Int32[]

If obj is a ValueType and a member of an array, arrayIndex contains the index within that array where obj exists. arrayIndex is ignored if obj is not both a ValueType and a member of an array.

Exception Condition
ArgumentNullException

The obj parameter is null.

ArgumentOutOfRangeException

The objectID parameter is less than or equal to zero.

SerializationException

The objectID has already been registered for an object other than obj, or member is not a FieldInfo and member isn't null.

You need to provide the member and idOfContainingObj parameters if obj is a ValueType because of the way fixups are performed on ValueType objects. The space to store the information for a ValueType is allocated inline with its containing object. However, when the ValueType is boxed to be registered with the ObjectManager, it loses the connection with its containing object. To guarantee that fixups occur in the instance of the ValueType stored in the containing object and not in the boxed instance, the ObjectManager retains some additional information.

ObjectManager retains information about both the object and its ID. Later during deserialization, GetObject can be used to discover whether a particular object ID has already been deserialized, or whether it is a forward reference to an object not yet deserialized.

.NET Framework
Available since 1.1
Return to top
Show: