Click or drag to resize
GCHandleAlloc Method (Object, GCHandleType)
Allocates a handle of the specified type for the specified object.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static GCHandle Alloc(
	Object value,
	GCHandleType type
)

Parameters

value
Type: SystemObject
The object that uses the GCHandle.
type
Type: System.Runtime.InteropServicesGCHandleType
One of the GCHandleType values, indicating the type of GCHandle to create.

Return Value

Type: GCHandle
A new GCHandle of the specified type. This GCHandle must be released with Free when it is no longer needed.
Exceptions
ExceptionCondition
ArgumentExceptionAn instance with nonprimitive (non-blittable) members cannot be pinned.
See Also