GCHandleAlloc Method (Object, GCHandleType) |
Allocates a handle of the specified type for the specified object.
Namespace: System.Runtime.InteropServicesAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax 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:
GCHandleA new
GCHandle of the specified type. This
GCHandle must be released with
Free when it is no longer needed.
Exceptions Exception | Condition |
---|
ArgumentException | An instance with nonprimitive (non-blittable) members cannot be pinned. |
See Also