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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access