C# and C++ interop

99 views Asked by At

I have a C++ function defined as

#define DllExport   __declspec( dllexport ) 
extern "C" DllExport void _stdcall CppAmp::square_array(float* arr, int n)

and c# code

[DllImport("C++AmpProject.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
        extern unsafe static void square_array(float* array, int length);

However I am getting an exception System.EntryPointNotFoundException

What am I doing wrong here?

2

There are 2 answers

1
fotg On

Turns out the argument names must match exactly.

0
SlaneR On

I think you should check via Dependency Walker before use it. Your function may not named like square_array