Condividi tramite


Interop Marshaling 

The audience for this section includes programmers who use platform invoke, COM interop, or both to marshal data. Certain marshaling rules and default data types differ between the two mechanisms:

  • If you use platform invoke, this section provides examples for marshaling strings, arrays, classes, structures, unions, and various miscellaneous types.

  • If you use COM interop, this section describes how to customize interop wrappers.

Interop marshaling governs how data is passed in method arguments and return values between managed and unmanaged memory during calls. Interop marshaling is a run-time activity performed by the common language runtime's marshaling service.

This section provides an overview of the interop marshaling service and presents detailed information about how data types that have different or ambiguous representations in unmanaged memory are marshaled. It also describes how to apply the MarshalAsAttribute attribute and use methods exposed by the Marshal class to alter the default marshaling behavior.

In This Section

  • Interop Marshaling Overview
    Describes the marshaling service, its relationship to COM marshaling, and its role in remote communications.
  • How to: Map HRESULTs and Exceptions
    Describes how to map custom exceptions to HRESULT and provides the complete mapping from each HRESULT to its comparable exception class in the .NET Framework.
  • Remote Objects
    Describes the various communications methods available in the .NET Framework for remote communications.