Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example of PInvoke from Linux with .NET Core
using System.Runtime.InteropServices;
namespace PInvokeSamples {
public static class Program {
// Import the libc and define the method corresponding to the native function.
[DllImport("libc.so.6")]
private static extern int getpid();
public static void Main(string[] args){
// Invoke the function and get the process ID.
int pid = getpid();
Console.WriteLine(pid);
}
}
}

wiwichu commented Jul 25, 2016

How do I call a c++ library I created from asp.net core in windows? I get a BadImageFormatException. In RC1 I was able to do it, but am not sure where to place the dll in asp.net core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment