问题
I'm really enjoying the dotnet core possibilities, but there are certain problems on Linux platform.
I was working with P/Invoke
stuff. It's fine on Windows, but when I tried to call function from libc
on Linux - I've got a problem:
Unhandled Exception: System.DllNotFoundException: Unable to load DLL '/usr/lib/x86_64-linux-gnu/libc.so': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I've tried two ways (source code http://pastebin.com/HDTnrM0a):
[DllImport("/usr/lib/x86_64-linux-gnu/libc.so")]
- and just
[DllImport("libc.so")]
Bot don't work and gave the same error. I've searched the certain file and it DOES EXIST:
root@ubuntu-512mb-ams2-01:/home/projects/pinvoke1# find / -name "libc.so"
/usr/lib/x86_64-linux-gnu/libc.so
PS, proof of using both variants:
来源:https://stackoverflow.com/questions/39563549/cant-pinvoke-libc-function-from-net-core-on-linux