Mono was originally designed to attract more windows. Net programmers to join the development of the Linux platform. However, in the Linux World, C language is still the mainstream. Most of the time, some key applications (such as the calculation of the product of a large flute card and the call of platform hardware functions) have to rely on C to complete the operation.
Mono is described through dllimport. The following is a sample code:
[Dllimport ("libc. So")]
Private Static extern int getpid ();
Of course, do not forget to add the namespace: system. runtime. interopservices
When this code is executed, Mono runtime will attempt to call getpid () in libc. So in the local system. If it is found, getpid () will be executed. Otherwise, dllnotfoundexception will be thrown.
The order of sharing library search for dllimport on Linux is as follows:
1./lib, for example, in/usr/lib
2. Most library files are cached in/etc/lD. so. cache, the file is written by/etc/lD. so. after the conf file is edited, run the ldconfig command to generate the file. then you can. so. add the directory of the so file in conf and run ldconfig.
3. Environment VariablesLD_LIBRARY_PATHDirectory
Related Articles:
How to use C to generate. So for mono call
C # precautions for dllimport C ++ DLL
Added copymemory support for C # in Linux