Here is the code in the C ++ dll:
extern "C" _declspec(dllexport) int testDelegate(int (*addFunction)(int, int), int a, int b)
{
int res = addFunction(a, b);
return res;
}
and here is the code in C #:
public delegate int AddIntegersDelegate(int number1, int number2);
public static int AddIntegers(int a, int b)
{
return a + b;
}
[DllImport("tester.dll", SetLastError = true)]
public static extern int testDelegate(AddIntegersDelegate callBackProc, int a, int b);
public static void Main(string[] args)
{
int result = testDelegate(AddIntegers, 4, 5);
Console.WriteLine("Code returned:" + result.ToString());
}
When I run this small application, I get a message from the header of this message. Can someone help please?
Thanks in advance,
D
source
share