რედაქტირება

გაზიარება არხიდან:


MarshalMode Enum

Definition

Represents the different marshalling modes used by CustomMarshallerAttribute to indicate when a marshaller applies.

public enum class MarshalMode
public enum MarshalMode
type MarshalMode = 
Public Enum MarshalMode
Inheritance
MarshalMode

Fields

Name Value Description
Default 0

All modes. A marshaller specified with this mode will be used if there's no specific marshaller for a given usage mode.

ManagedToUnmanagedIn 1

By-value and in parameters in managed-to-unmanaged scenarios, like P/Invoke.

ManagedToUnmanagedRef 2

ref parameters in managed-to-unmanaged scenarios, like P/Invoke.

ManagedToUnmanagedOut 3

out parameters and return values in managed-to-unmanaged scenarios, like P/Invoke. The marshaller converts from the unmanaged type to the managed type.

UnmanagedToManagedIn 4

By-value and in parameters in unmanaged-to-managed scenarios, like Reverse P/Invoke.

UnmanagedToManagedRef 5

ref parameters in unmanaged-to-managed scenarios, like Reverse P/Invoke.

UnmanagedToManagedOut 6

out parameters and return values in unmanaged-to-managed scenarios, like Reverse P/Invoke. The marshaller converts from the managed type to the unmanaged type.

ElementIn 7

Elements of arrays passed with in or by-value in interop scenarios.

ElementRef 8

Elements of arrays passed with ref or passed by-value with both InAttribute and OutAttribute in interop scenarios.

ElementOut 9

Elements of arrays passed with out or passed by-value with only OutAttribute in interop scenarios.

Remarks

Each member name follows the pattern {CallDirection}{DataFlow}:

  • Call direction (ManagedToUnmanaged or UnmanagedToManaged) indicates which side initiates the call. ManagedToUnmanaged applies to P/Invoke calls. UnmanagedToManaged applies to Reverse P/Invoke or COM scenarios where native code calls into managed code.
  • Data flow (In, Out, or Ref) indicates how data moves relative to the call. In means data flows from caller to callee. Out means data flows from callee to caller, which includes both out parameters and return values. Ref means data flows in both directions.

For example, ManagedToUnmanagedOut applies when managed code calls unmanaged code (P/Invoke) and data flows back to the caller — this covers out parameters and return values. The marshaller for this mode converts from the unmanaged type to the managed type.

Applies to