Marshal.PtrToStructure Method (IntPtr, Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Marshals data from an unmanaged block of memory to a managed object.

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

[<SecurityCriticalAttribute>]
[<ComVisibleAttribute(true)>]
static member PtrToStructure : 
        ptr:nativeint *
        structure:Object -> unit

Parameters

ptr
Type: System.IntPtr

A pointer to an unmanaged block of memory.

structure
Type: System.Object

The object to which the data is to be copied. This must be an instance of a formatted class.

Exception Condition
ArgumentException

Structure layout is not sequential or explicit.

-or-

Structure is a boxed value type.

PtrToStructure is often necessary in COM interop and platform invoke when structure parameters are represented as an System.IntPtr value. You cannot use this overload method with value types.

SecurityCriticalAttribute

requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: