Common Interoperability Issues

The primary issues that arise when using any of these interoperability mechanisms are twofold. First, you must make the code on one side of the managed/unmanaged boundary visible to code on the other; otherwise, it cannot be called. To one degree or another, .NET provides options for this in all cases.

Second, the parameters have to be marshaled back and forth across the managed/unmanaged boundary to cater for the difference between managed and unmanaged data types. After all, a Win32 PChar is markedly different from a .NET String or StringBuilder class. The Interop Marshaler does a fine job of providing default marshaling for most parameter types that we are likely to use.

One issue that isn’t so obvious relates ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.