4 out of 8 rated this helpful - Rate this topic

System.Runtime.InteropServices Namespace

The System.Runtime.InteropServices namespace provides a wide variety of members that support COM interop and platform invoke services. If you are unfamiliar with these services, see Interoperating with Unmanaged Code.

Members of this namespace provide several categories of functionality, as shown in the following table. Attributes control marshaling behavior, such as how to arrange structures or how to represent strings. The most important attributes are DllImportAttribute, which you use to define platform invoke methods for accessing unmanaged APIs, and MarshalAsAttribute, which you use to specify how data is marshaled between managed and unmanaged memory.

  Class Description
Public class AutomationProxyAttribute Specifies whether the type should be marshaled using the Automation marshaler or a custom proxy and stub.
Public class BestFitMappingAttribute Controls whether Unicode characters are converted to the closest matching ANSI characters.
Public class BStrWrapper Marshals data of type VT_BSTR from managed to unmanaged code. This class cannot be inherited.
Public class ClassInterfaceAttribute Indicates the type of class interface to be generated for a class exposed to COM, if an interface is generated at all.
Public class CoClassAttribute Specifies the class identifier of a coclass imported from a type library.
Public class ComAliasNameAttribute Indicates the COM alias for a parameter or field type.
Public class ComCompatibleVersionAttribute Indicates to a COM client that all classes in the current version of an assembly are compatible with classes in an earlier version of the assembly.
Public class ComConversionLossAttribute Indicates that information was lost about a class or interface when it was imported from a type library to an assembly.
Public class ComDefaultInterfaceAttribute Specifies a default interface to expose to COM. This class cannot be inherited.
Public class ComEventInterfaceAttribute Identifies the source interface and the class that implements the methods of the event interface that is generated when a coclass is imported from a COM type library.
Public class COMException The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.
Public class ComImportAttribute Indicates that the attributed type was previously defined in COM.
Public class ComRegisterFunctionAttribute Specifies the method to call when you register an assembly for use from COM; this allows for the execution of user-written code during the registration process.
Public class ComSourceInterfacesAttribute Identifies a list of interfaces that are exposed as COM event sources for the attributed class.
Public class ComUnregisterFunctionAttribute Specifies the method to call when you unregister an assembly for use from COM; this allows for the execution of user-written code during the unregistration process.
Public class ComVisibleAttribute Controls accessibility of an individual managed type or member, or of all types within an assembly, to COM.
Public class CriticalHandle Represents a wrapper class for handle resources.
Public class CurrencyWrapper Wraps objects the marshaler should marshal as a VT_CY.
Public class DefaultCharSetAttribute Specifies the value of the CharSet enumeration. This class cannot be inherited.
Public class DefaultParameterValueAttribute Sets the default value of a parameter when called from a language that supports default parameters. This class cannot be inherited.
Public class DispatchWrapper Wraps objects the marshaler should marshal as a VT_DISPATCH.
Public class DispIdAttribute Specifies the COM dispatch identifier (DISPID) of a method, field, or property.
Public class DllImportAttribute Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point.
Public class ErrorWrapper Wraps objects the marshaler should marshal as a VT_ERROR.
Public class ExtensibleClassFactory Enables customization of managed objects that extend from unmanaged objects during creation.
Public class ExternalException The base exception type for all COM interop exceptions and structured exception handling (SEH) exceptions.
Public class FieldOffsetAttribute Indicates the physical position of fields within the unmanaged representation of a class or structure.
Public class GuidAttribute Supplies an explicit System.Guid when an automatic GUID is undesirable.
Public class HandleCollector Tracks outstanding handles and forces a garbage collection when the specified threshold is reached.
Public class IDispatchImplAttribute Indicates which IDispatch implementation the common language runtime uses when exposing dual interfaces and dispinterfaces to COM.
Public class ImportedFromTypeLibAttribute Indicates that the types defined within an assembly were originally defined in a type library.
Public class InAttribute Indicates that data should be marshaled from the caller to the callee, but not back to the caller.
Public class InterfaceTypeAttribute Indicates whether a managed interface is dual, dispatch-only, or IUnknown -only when exposed to COM.
Public class InvalidComObjectException The exception thrown when an invalid COM object is used.
Public class InvalidOleVariantTypeException The exception thrown by the marshaler when it encounters an argument of a variant type that can not be marshaled to managed code.
Public class LCIDConversionAttribute Indicates that a method's unmanaged signature expects a locale identifier (LCID) parameter.
Public class Marshal 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.
Public class MarshalAsAttribute Indicates how to marshal the data between managed and unmanaged code.
Public class MarshalDirectiveException The exception that is thrown by the marshaler when it encounters a MarshalAsAttribute it does not support.
Public class OptionalAttribute Indicates that a parameter is optional.
Public class OutAttribute Indicates that data should be marshaled from callee back to caller.
Public class PreserveSigAttribute Indicates that the HRESULT or retval signature transformation that takes place during COM interop calls should be suppressed.
Public class PrimaryInteropAssemblyAttribute Indicates that the attributed assembly is a primary interop assembly.
Public class ProgIdAttribute Allows the user to specify the ProgID of a class.
Public class RegistrationServices Provides a set of services for registering and unregistering managed assemblies for use from COM.
Public class RuntimeEnvironment Provides a collection of static methods that return information about the common language runtime environment.
Public class SafeArrayRankMismatchException The exception thrown when the rank of an incoming SAFEARRAY does not match the rank specified in the managed signature.
Public class SafeArrayTypeMismatchException The exception thrown when the type of the incoming SAFEARRAY does not match the type specified in the managed signature.
Public class SafeHandle Represents a wrapper class for operating system handles.
Public class SEHException Represents Structured Exception Handler (SEH) errors.
Public class SetWin32ContextInIDispatchAttribute This attribute has been deprecated.
Public class StandardOleMarshalObject Replaces the standard common language runtime (CLR) free-threaded marshaler with the standard OLE STA marshaler.
Public class StructLayoutAttribute The StructLayoutAttribute class allows the user to control the physical layout of the data fields of a class or structure.
Public class TypeLibConverter Provides a set of services that convert a managed assembly to a COM type library and vice versa.
Public class TypeLibFuncAttribute Contains the FUNCFLAGS that were originally imported for this method from the COM type library.
Public class TypeLibImportClassAttribute Specifies which Type exclusively uses an interface. This class cannot be inherited.
Public class TypeLibTypeAttribute Contains the TYPEFLAGS that were originally imported for this type from the COM type library.
Public class TypeLibVarAttribute Contains the VARFLAGS that were originally imported for this field from the COM type library.
Public class TypeLibVersionAttribute Specifies the version number of an exported type library.
Public class UnknownWrapper Wraps objects the marshaler should marshal as a VT_UNKNOWN.
Public class UnmanagedFunctionPointerAttribute Controls the marshaling behavior of a delegate signature passed as an unmanaged function pointer to or from unmanaged code. This class cannot be inherited.
Public class VariantWrapper Marshals data of type VT_VARIANT | VT_BYREF from managed to unmanaged code. This class cannot be inherited.
  Interface Description
Public interface _Activator Exposes the System.Activator class to unmanaged code.
Public interface _Assembly Exposes the public members of the System.Reflection.Assembly class to unmanaged code.
Public interface _AssemblyBuilder Exposes the System.Reflection.Emit.AssemblyBuilder class to unmanaged code.
Public interface _AssemblyName Exposes the AssemblyName class to unmanaged code.
Public interface _Attribute Exposes the System.Attribute class to unmanaged code.
Public interface _ConstructorBuilder Exposes the System.Reflection.Emit.ConstructorBuilder class to unmanaged code.
Public interface _ConstructorInfo Exposes the public members of the System.Reflection.ConstructorInfo class to unmanaged code.
Public interface _CustomAttributeBuilder Exposes the System.Reflection.Emit.CustomAttributeBuilder class to unmanaged code.
Public interface _EnumBuilder Exposes the System.Reflection.Emit.EnumBuilder class to unmanaged code.
Public interface _EventBuilder Exposes the System.Reflection.Emit.EventBuilder class to unmanaged code.
Public interface _EventInfo Exposes the public members of the System.Reflection.EventInfo class to unmanaged code.
Public interface _Exception Exposes the public members of the System.Exception class to unmanaged code.
Public interface _FieldBuilder Exposes the System.Reflection.Emit.FieldBuilder class to unmanaged code.
Public interface _FieldInfo Exposes the public members of the System.Reflection.FieldInfo class to unmanaged code.
Public interface _ILGenerator Exposes the System.Reflection.Emit.ILGenerator class to unmanaged code.
Public interface _LocalBuilder Exposes the System.Reflection.Emit.LocalBuilder class to unmanaged code.
Public interface _MemberInfo Exposes the public members of the System.Reflection.MemberInfo class to unmanaged code.
Public interface _MethodBase Exposes the public members of the System.Reflection.MethodBase class to unmanaged code.
Public interface _MethodBuilder Exposes the MethodBuilder class to unmanaged code.
Public interface _MethodInfo Exposes the public members of the System.Reflection.MethodInfo class to unmanaged code.
Public interface _MethodRental Exposes the System.Reflection.Emit.MethodRental class to unmanaged code.
Public interface _Module Exposes the Module class to unmanaged code.
Public interface _ModuleBuilder Exposes the System.Reflection.Emit.ModuleBuilder class to unmanaged code.
Public interface _ParameterBuilder Exposes the System.Reflection.Emit.ParameterBuilder class to unmanaged code.
Public interface _ParameterInfo Exposes the System.Reflection.ParameterInfo class to unmanaged code.
Public interface _PropertyBuilder Exposes the System.Reflection.Emit.PropertyBuilder class to unmanaged code.
Public interface _PropertyInfo Exposes the public members of the System.Reflection.PropertyInfo class to unmanaged code.
Public interface _SignatureHelper Exposes the System.Reflection.Emit.SignatureHelper class to unmanaged code.
Public interface _Thread Exposes the System.Threading.Thread class to unmanaged code.
Public interface _Type Exposes the public members of the System.Type class to the unmanaged code.
Public interface _TypeBuilder Exposes the System.Reflection.Emit.TypeBuilder class to unmanaged code.
Public interface ICustomAdapter Provides a way for clients to access the actual object, rather than the adapter object handed out by a custom marshaler.
Public interface ICustomFactory Enables users to write activation code for managed objects that extend MarshalByRefObject.
Public interface ICustomMarshaler Designed to provide custom wrappers for handling method calls.
Public interface IRegistrationServices Provides a set of services for registering and unregistering managed assemblies for use from COM.
Public interface ITypeLibConverter Provides a set of services that convert a managed assembly to a COM type library and vice versa.
Public interface ITypeLibExporterNameProvider Provides control over the casing of names when exported to a type library.
Public interface ITypeLibExporterNotifySink Provides a callback mechanism for the assembly converter to inform the caller of the status of the conversion, and involve the caller in the conversion process itself.
Public interface ITypeLibImporterNotifySink Provides a callback mechanism for the type library converter to inform the caller of the status of the conversion, and involve the caller in the conversion process itself.
Public interface UCOMIBindCtx Use BIND_OPTS instead.
Public interface UCOMIConnectionPoint Use IConnectionPoint instead.
Public interface UCOMIConnectionPointContainer Use IConnectionPointContainer instead.
Public interface UCOMIEnumConnectionPoints Use IEnumConnectionPoints instead.
Public interface UCOMIEnumConnections Use IEnumConnections instead.
Public interface UCOMIEnumMoniker Use IEnumMoniker instead.
Public interface UCOMIEnumString Use IEnumString instead.
Public interface UCOMIEnumVARIANT Use IEnumVARIANT instead.
Public interface UCOMIMoniker Use IMoniker instead.
Public interface UCOMIPersistFile Note: This interface is now obsolete. Use IPersistFile instead.
Public interface UCOMIRunningObjectTable Use IRunningObjectTable instead.
Public interface UCOMIStream Use IStream instead.
Public interface UCOMITypeComp Use ITypeComp instead.
Public interface UCOMITypeInfo Use ITypeInfo instead.
Public interface UCOMITypeLib Use ITypeLib instead.
  Structure Description
Public structure ArrayWithOffset Encapsulates an array and an offset within the specified array.
Public structure BIND_OPTS Use BIND_OPTS instead.
Public structure BINDPTR Use BINDPTR instead.
Public structure CONNECTDATA Use CONNECTDATA instead.
Public structure DISPPARAMS Use DISPPARAMS instead.
Public structure ELEMDESC Use ELEMDESC instead.
Public structure ELEMDESC.DESCUNION Use ELEMDESC.DESCUNION instead.
Public structure EXCEPINFO Use EXCEPINFO instead.
Public structure FILETIME Use FILETIME instead.
Public structure FUNCDESC Use FUNCDESC instead.
Public structure GCHandle Provides a means for accessing a managed object from unmanaged memory.
Public structure HandleRef Wraps a managed object holding a handle to a resource that is passed to unmanaged code using platform invoke.
Public structure IDLDESC Use IDLDESC instead.
Public structure PARAMDESC Use PARAMDESC instead.
Public structure STATSTG Use STATSTG instead.
Public structure TYPEATTR Use TYPEATTR instead.
Public structure TYPEDESC Use TYPEDESC instead.
Public structure TYPELIBATTR Use TYPELIBATTR instead.
Public structure VARDESC Use VARDESC instead.
Public structure VARDESC.DESCUNION Note: this structure is obsolete. Use VARDESC.DESCUNION instead.
  Delegate Description
Public delegate ObjectCreationDelegate Creates a COM object.
  Enumeration Description
Public enumeration AssemblyRegistrationFlags Defines a set of flags used when registering assemblies.
Public enumeration CALLCONV Use CALLCONV instead.
Public enumeration CallingConvention Specifies the calling convention required to call methods implemented in unmanaged code.
Public enumeration CharSet Dictates which character set marshaled strings should use.
Public enumeration ClassInterfaceType Identifies the type of class interface that is generated for a class.
Public enumeration ComInterfaceType Identifies how to expose an interface to COM.
Public enumeration ComMemberType Describes the type of a COM member.
Public enumeration DESCKIND Use DESCKIND instead.
Public enumeration ExporterEventKind Describes the callbacks that the type library exporter makes when exporting a type library.
Public enumeration FUNCFLAGS Use FUNCFLAGS instead.
Public enumeration FUNCKIND Use FUNCKIND instead.
Public enumeration GCHandleType Represents the types of handles the GCHandle class can allocate.
Public enumeration IDispatchImplType Indicates which IDispatch implementation to use for a particular class.
Public enumeration IDLFLAG Use IDLFLAG instead.
Public enumeration IMPLTYPEFLAGS Use IMPLTYPEFLAGS instead.
Public enumeration ImporterEventKind Describes the callbacks that the type library importer makes when importing a type library.
Public enumeration INVOKEKIND Use INVOKEKIND instead.
Public enumeration LayoutKind Controls the layout of an object when exported to unmanaged code.
Public enumeration LIBFLAGS Use LIBFLAGS instead.
Public enumeration PARAMFLAG Use PARAMFLAG instead.
Public enumeration RegistrationClassContext Specifies the set of execution contexts in which a class object will be made available for requests to construct instances.
Public enumeration RegistrationConnectionType Defines the types of connections to a class object.
Public enumeration SYSKIND Use SYSKIND instead.
Public enumeration TYPEFLAGS Use TYPEFLAGS instead.
Public enumeration TYPEKIND Use TYPEKIND instead.
Public enumeration TypeLibExporterFlags Indicates how a type library should be produced.
Public enumeration TypeLibFuncFlags Describes the original settings of the FUNCFLAGS in the COM type library from where this method was imported.
Public enumeration TypeLibImporterFlags Indicates how an assembly should be produced.
Public enumeration TypeLibTypeFlags Describes the original settings of the TYPEFLAGS in the COM type library from which the type was imported.
Public enumeration TypeLibVarFlags Describes the original settings of the VARFLAGS in the COM type library from which the variable was imported.
Public enumeration UnmanagedType Identifies how to marshal parameters or fields to unmanaged code.
Public enumeration VarEnum Indicates how to marshal the array elements when an array is marshaled from managed to unmanaged code as a UnmanagedType.SafeArray.
Public enumeration VARFLAGS Use VARFLAGS instead.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ