System.Reflection.Emit.UnmanagedMarshal Class

Assembly: Mscorlib.dll
Namespace: System.Reflection.Emit
Summary
Represents the class that describes how to marshal a field from managed to unmanaged code. This class cannot be inherited.
C# Syntax:
[Serializable]
public sealed class UnmanagedMarshal
Thread Safety
Reflection Emit is thread-safe when using assemblies that were created with the AppDomain.DefineDynamicAssembly method with the Boolean parameter isSynchronized set to true.
Remarks
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.
See also:
System.Reflection.Emit Namespace | Type | UnmanagedType | Guid

System.Reflection.Emit.UnmanagedMarshal Member List:

Public Properties
BaseType Read-only

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

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

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

Gets a GUID. This property is read-only.
Public Methods
DefineByValArray Specifies a fixed-length array (ByValArray) to marshal to unmanaged code.
DefineByValTStr Specifies a string in a fixed array buffer (ByValTStr) to marshal to unmanaged code.
DefineLPArray 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.
DefineUnmanagedMarshal Specifies a given type that is to be marshaled to unmanaged code.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Reflection.Emit.UnmanagedMarshal Member Details

Property: BaseType (read-only)
Summary
Gets an unmanaged base type. This property is read-only.
C# Syntax:
public UnmanagedType BaseType {get;}
Exceptions
Exception Type Condition
ArgumentException The unmanaged type is not an LPArray or a SafeArray.
See also:
UnmanagedType

Return to top


Property: ElementCount (read-only)
Summary
Gets a number element. This property is read-only.
C# Syntax:
public int ElementCount {get;}
Exceptions
Exception Type Condition
ArgumentException The argument is not an unmanaged element count.
Remarks
There is an ElementCount only if there is a NativeTypeFixedArray.

Return to top


Property: GetUnmanagedType (read-only)
Summary
Indicates an unmanaged type. This property is read-only.
C# Syntax:
public UnmanagedType GetUnmanagedType {get;}
Remarks
The GetUnmanagedType property is an accessor function for the native type.
See also:
UnmanagedType

Return to top


Property: IIDGuid (read-only)
Summary
Gets a GUID. This property is read-only.
C# Syntax:
public Guid IIDGuid {get;}
Exceptions
Exception Type Condition
ArgumentException The argument is not a custom marshaler.
Remarks
This property always returns Guid.Empty. This property might be removed in a future release.
See also:
Int32 | Guid

Return to top


Method: DefineByValArray(
   int elemCount
)
Summary
Specifies a fixed-length array (ByValArray) to marshal to unmanaged code.
C# Syntax:
public static UnmanagedMarshal DefineByValArray(
   int elemCount
);
Parameters:

elemCount

The number of elements in the fixed-length array.

Return Value:
An UnmanagedMarshal object.
Exceptions
Exception Type Condition
ArgumentException The argument is not a simple native type.
Remarks
The DefineByValArray method is not a simple native marshal.

Only unmanaged marshal constructs can be made using these static constructors.

Marshaling an array is a more complex process than marshaling an integer parameter. Array members are copied in a specific order so that the other side can reconstruct the array exactly.

See also:
UnmanagedType

Return to top


Method: DefineByValTStr(
   int elemCount
)
Summary
Specifies a string in a fixed array buffer (ByValTStr) to marshal to unmanaged code.
C# Syntax:
public static UnmanagedMarshal DefineByValTStr(
   int elemCount
);
Parameters:

elemCount

The number of elements in the fixed array buffer.

Return Value:
An UnmanagedMarshal object.
Exceptions
Exception Type Condition
ArgumentException The argument is not a simple native type.
Remarks
The DefineByValStr method is not a simple native marshal.

Only unmanaged marshal constructs can be made using these static constructors.

Marshaling an array is a more complex process than marshaling an integer parameter. Array members are copied in a specific order so that the other side can reconstruct the array exactly.

See also:
Int32 | Array | String | UnmanagedType

Return to top


Method: DefineLPArray(
   UnmanagedType elemType
)
Summary
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.
C# Syntax:
public static UnmanagedMarshal DefineLPArray(
   UnmanagedType elemType
);
Parameters:

elemType

The unmanaged type to which to marshal the array.

Return Value:
An UnmanagedMarshal object.
Exceptions
Exception Type Condition
ArgumentException The argument is not a simple native type.
Remarks
The DefineLPArray method is not a simple native marshal.

Only unmanaged marshal constructs can be made using these static constructors.

Marshaling an array is a more complex process than marshaling an integer parameter. Array members are copied in a specific order so that the other side can reconstruct the array exactly.

See also:
UnmanagedType

Return to top


Method: DefineUnmanagedMarshal(
   UnmanagedType unmanagedType
)
Summary
Specifies a given type that is to be marshaled to unmanaged code.
C# Syntax:
public static UnmanagedMarshal DefineUnmanagedMarshal(
   UnmanagedType unmanagedType
);
Parameters:

unmanagedType

The unmanaged type to which the type is to be marshaled.

Return Value:
An UnmanagedMarshal object.
Exceptions
Exception Type Condition
ArgumentException The argument is not a simple native type.
Remarks
The DefineUnmanagedMarshal method is not a simple native marshal. Only unmanaged marshal constructs can be made using these static constructors.
See also:
UnmanagedType

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~UnmanagedMarshal();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.