Skip to content
Advertisement

How do I call native Linux and OS X API from .NET Core application?

I need to call file management functions that are not present in .NET Core. How do I call native Linux and Mac OS X API from my C# code?

Edit: The only answer to this question doesn’t include any definitive information. Can someone post some code samples or more concrete details about how to invoke Mac OS X APIs from .NET Core?

Advertisement

Answer

.NET has a feature called PInvoke (platform invoke) that allows you to call native APIs.

However, getting it to work is not trivial. You need to import the correct platform library. There will also be a performance impact

Check out these links

https://learn.microsoft.com/en-us/dotnet/articles/standard/native-interop https://developers.redhat.com/blog/2016/09/14/pinvoke-in-net-core-rhel/

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement