.NET PInvoke是否可在Linux和Mac OS X平台上使用?

Ami*_*yan 5 .net c# linux macos pinvoke

Windows上可以使用.NET Framework中的Platform Invokation.

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern MessageBoxResult MessageBox(IntPtr hWnd, String text, String caption, int options);
Run Code Online (Sandbox Code Playgroud)

PInvoke是否可在Linux和Mac OS X平台上使用?例如Mono项目?

如果Linux和Mac OS X支持PInvoke,您能否在答案中给我一些示例或参考.

谢谢.

Rob*_*vey 9

与本机库互操作
http://www.mono-project.com/Interop_with_Native_Libraries

  • 简而言之:是的,Linux和MacOS X支持P/Invoke.但是,不支持调用特定于Windows的库,如"user32.dll",因为Linux和MacOS X不是Windows. (4认同)