This documentation is archived and is not being maintained.

GCHandle.AddrOfPinnedObject Method

Retrieves the address of an object in a Pinned handle.

[Visual Basic]
Public Function AddrOfPinnedObject() As IntPtr
public IntPtr AddrOfPinnedObject();
public: IntPtr AddrOfPinnedObject();
public function AddrOfPinnedObject() : IntPtr;

Return Value

The address of the of the Pinned object as an IntPtr.


Exception Type Condition
InvalidOperationException The handle is any type other than Pinned.


This method is used to get a stable pointer to the object. Pinning an object prevents the garbage collector from moving it around in memory, thereby reducing the efficiency of the garbage collector.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

GCHandle Structure | GCHandle Members | System.Runtime.InteropServices Namespace | GCHandleType