Hello all!
My main.c in C code:
Code:
#include <stdio.h>void main()
{
printf("Hello world\n");
}
I'm running gcc main.c -o main.dll using Terminal. .Net Core console app:
Code:
using System;using System.Runtime.InteropServices;
namespace dllimportc
{
class Program
{
static void Main()
{
Console.WriteLine("Hello World!");
main();
Console.ReadLine();
}
[DllImport("main.dll", EntryPoint = "main", CallingConvention = CallingConvention.Cdecl)]
public static extern void main ();
}
}
I've got an error:
Exception has occurred: CLR/System.EntryPointNotFoundExceptionAn unhandled exception of type 'System.EntryPointNotFoundException' occurred in dllimportc.dll: 'Unable to find an entry point named 'main' in shared library 'main.dll'.'
at dllimportc.Program.main()
at dllimportc.Program.Main()
How to run my C code from C#?