Mono Class Library: System.Runtime.InteropServices.GCHandle Overview | Members

System.Runtime.InteropServices.GCHandle.Alloc Method

Allocates a GCHandleType.Normal handle for the specified object.

public static GCHandle Alloc (object value)

Parameters

value
The object for which the System.Runtime.InteropServices.GCHandle is created. Can be null .

Returns

A new System.Runtime.InteropServices.GCHandle instance that protects the object from garbage collection.

Permissions

TypeReason
System.Security.Permissions.SecurityPermissionRequires permission to call unmanaged code. See System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode .

Remarks

A GCHandleType.Normal handle ensures the object will not be collected by the garbage collector.

If the value parameter is null, this method returns a valid System.Runtime.InteropServices.GCHandle.

Note: The target of the handle can be changed via the GCHandle.Target property.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0