C# wrapper of c++ dll; "Run-Time Check Failure #0 - The value of ESP was not properly saved across a
- by Deveti Putnik
Here is the code in 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 start this small app, I get the message from the header of this post. Can someone help, please?
Thanks in advance,
D