Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

P/Invoke in Mono

Tags:

What's the current status of Mono's Platform Invoke implementation on Linux and on Solaris?

like image 603
Dmitry Shechtman Avatar asked Aug 30 '08 10:08

Dmitry Shechtman


People also ask

How does P invoke work?

P/Invoke is a technology that allows you to access structs, callbacks, and functions in unmanaged libraries from your managed code. Most of the P/Invoke API is contained in two namespaces: System and System. Runtime. InteropServices .

What is PInvoke signature?

* The term PInvoke is derived from the phrase "Platform Invoke". PInvoke signatures are native method signatures, also known as Declare statements in VB.

What is interop in C#?

Interoperability enables you to preserve and take advantage of existing investments in unmanaged code. Code that runs under the control of the common language runtime (CLR) is called managed code, and code that runs outside the CLR is called unmanaged code.


1 Answers

Working, usable and stable. It's well tested since quite a lot of mono's own low-level functionality has to be marshaled through it to the underlying operating system.

There are some P/Invoke extensions when compared to Microsoft .Net implementation (after all they deal with a single OS family and three architectures at most). Most notable of those would be that library mappings transform the library name to OS-specific variants (e.g. mylib.dll searches for mylib.so on Linux, mylib.dylib on OS X and so on) and take into account various other system specific conventions. There is also a DLLMap configuration extension which can be used if the default name translations are not enough. Usually it's convenient to have the same API of the binary lib exposed on different OSes, so that migrating between platforms only requires changes in the C code, not the .Net part.

like image 117
skolima Avatar answered Oct 15 '22 09:10

skolima