Edit

Share via


UnmanagedMarshal Class

Definition

Caution

An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202

Represents the class that describes how to marshal a field from managed to unmanaged code. This class cannot be inherited.

public ref class UnmanagedMarshal sealed
[System.Serializable]
public sealed class UnmanagedMarshal
[System.Serializable]
[System.Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class UnmanagedMarshal
[<System.Serializable>]
type UnmanagedMarshal = class
[<System.Serializable>]
[<System.Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type UnmanagedMarshal = class
Public NotInheritable Class UnmanagedMarshal
Inheritance
UnmanagedMarshal
Attributes

Remarks

The code example shows the workaround for this obsolete type.

Marshaling is the process of packaging and unpackaging parameters so remote procedure calls can occur. During marshaling, a field might undergo a format conversion when the format of the managed type is different from the format of the corresponding unmanaged type. For example, you might want to marshal a String type as an unmanaged BSTR. Some format conversions are handled automatically by the runtime. To override the default behavior, you must use the UnmanagedMarshal class to define the format conversion.

Properties

BaseType

Gets an unmanaged base type. This property is read-only.

ElementCount

Gets a number element. This property is read-only.

GetUnmanagedType

Indicates an unmanaged type. This property is read-only.

IIDGuid

Gets a GUID. This property is read-only.

Methods

DefineByValArray(Int32)

Specifies a fixed-length array (ByValArray) to marshal to unmanaged code.

DefineByValTStr(Int32)

Specifies a string in a fixed array buffer (ByValTStr) to marshal to unmanaged code.

DefineLPArray(UnmanagedType)

Specifies an LPArray to marshal to unmanaged code. The length of an LPArray is determined at runtime by the size of the actual marshaled array.

DefineSafeArray(UnmanagedType)

Specifies a SafeArray to marshal to unmanaged code.

DefineUnmanagedMarshal(UnmanagedType)

Specifies a given type that is to be marshaled to unmanaged code.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also