Platform Invocation Services - Tools

Tools

There are a number of tools which are designed to aid in the production of P/Invoke signatures.

Writing a utility application that would import C++ header files and native DLL files and produce an interface assembly automatically turns out to be quite difficult. The main problem with producing such an importer/exporter for P/Invoke signatures is the ambiguity of some C++ function call parameter types.

Brad Abrams has this to say on the subject: The P/Invoke Problem.

The problem lies with C++ functions like the following:

__declspec(dllexport) void MyFunction(char *params);

What type should we use for the parameter params in our P/Invoke signature ? This could be either a C++ null terminated string, or could be a char array or could be an output char parameter. So should we use string, StringBuilder, char or ref char ?

Regardless of this issue, there are a few tools available to make the production of P/Invoke signatures simpler.

One of the tools listed below, C#/.NET P/Invoke Interop SDK has actually successfully resolved this issue by implementing multiple overrides of the same C++ method in .NET world, developers can then pick the correct one to make the call.

Read more about this topic:  Platform Invocation Services

Famous quotes containing the word tools:

    Armies, though always the supporters and tools of absolute power for the time being, are always the destroyers of it too; by frequently changing the hands in which they think proper to lodge it.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)

    Think of the tools in a tool-box: there is a hammer, pliers, a saw, a screwdriver, a rule, a glue-pot, nails and screws.—The function of words are as diverse as the functions of these objects.
    Ludwig Wittgenstein (1889–1951)

    No man is born into the world, whose work
    Is not born with him; there is always work,
    And tools to work withal, for those who will:
    And blessèd are the horny hands of toil!
    James Russell Lowell (1819–1891)