System.Runtime.InteropServices Namespace

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

The System.Runtime.InteropServices namespace provides types that support COM interop and platform invoke services.

Classes

  Class Description
AllowReversePInvokeCallsAttribute Allows an unmanaged method to call a managed method.
ClassInterfaceAttribute Infrastructure. Indicates the type of class interface to be generated for a class exposed to COM, if an interface is generated at all.
CoClassAttribute Infrastructure. Specifies the class identifier of a coclass imported from a type library.
ComDefaultInterfaceAttribute Infrastructure. Specifies a default interface to expose to COM. This class cannot be inherited.
COMException Infrastructure. The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.
ComImportAttribute Infrastructure. Indicates that the attributed type was previously defined in COM.
ComVisibleAttribute Infrastructure. Controls accessibility of an individual managed type or member, or of all types within an assembly, to COM.
CriticalHandle Infrastructure. Represents a wrapper class for handle resources.
DefaultCharSetAttribute Infrastructure. Specifies the value of the CharSet enumeration. This class cannot be inherited.
DispIdAttribute Infrastructure. Specifies the COM dispatch identifier (DISPID) of a method, field, or property.
DllImportAttribute Infrastructure. Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point.
ExternalException Infrastructure. The base exception type for all COM interop exceptions and structured exception handling (SEH) exceptions.
FieldOffsetAttribute Infrastructure. Indicates the physical position of fields within the managed and unmanaged representation of a class or structure.
GuidAttribute Infrastructure. Supplies an explicit System..::.Guid when an automatic GUID is undesirable.
InAttribute Infrastructure. Indicates that data should be marshaled from the caller to the callee, but not back to the caller.
InterfaceTypeAttribute Infrastructure. Indicates whether a managed interface is dual, dispatch-only, or IUnknown -only when exposed to COM.
Marshal Infrastructure. Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.
MarshalAsAttribute Infrastructure. Indicates how to marshal the data between managed and unmanaged code.
MarshalDirectiveException Infrastructure. The exception that is thrown by the marshaler when it encounters a MarshalAsAttribute it does not support.
OptionalAttribute Infrastructure. Indicates that a parameter is optional.
OutAttribute Infrastructure. Indicates that data should be marshaled from callee back to caller.
PreserveSigAttribute Infrastructure. Indicates that the HRESULT or retval signature transformation that takes place during COM interop calls should be suppressed.
SafeHandle Infrastructure. Represents a wrapper class for operating system handles. This class must be inherited.
SEHException Infrastructure. Represents Structured Exception Handler (SEH) errors.
StructLayoutAttribute Infrastructure. The StructLayoutAttribute class allows the user to control the physical layout of the data fields of a class or structure.
UnmanagedFunctionPointerAttribute Infrastructure. Controls the marshaling behavior of a delegate signature passed as an unmanaged function pointer to or from unmanaged code. This class cannot be inherited.

Structures

  Structure Description
GCHandle Infrastructure. Provides a means for accessing a managed object from unmanaged memory.

Interfaces

  Interface Description
ICustomQueryInterface Enables developers to provide a custom, managed implementation of the IUnknown::QueryInterface(REFIID riid, void **ppvObject) method.

Enumerations

  Enumeration Description
CallingConvention Infrastructure. Specifies the calling convention required to call methods implemented in unmanaged code.
CharSet Infrastructure. Dictates which character set marshaled strings should use.
ClassInterfaceType Infrastructure. Identifies the type of class interface that is generated for a class.
ComInterfaceType Infrastructure. Identifies how to expose an interface to COM.
CustomQueryInterfaceMode Indicates whether IUnknown::QueryInterface calls can use the ICustomQueryInterface interface.
CustomQueryInterfaceResult Provides return values for the GetInterface method.
GCHandleType Infrastructure. Represents the types of handles the GCHandle class can allocate.
LayoutKind Infrastructure. Controls the layout of an object when exported to unmanaged code.
UnmanagedType Infrastructure. Identifies how to marshal parameters or fields to unmanaged code.