Can't pinvoke libc function from .NET core on Linux

不打扰是莪最后的温柔 提交于 2019-12-11 05:54:23

问题


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 libcon 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!