In my dll there is a method that I want to export.
//Works:
extern "C" __declspec(dllexport)
//Wont work
__declspec(dllexport)
C++ Export:
extern "C" __declspec(dllexport) int Test();
C# import:
[DllImport("CircleGPU2_32.DLL", EntryPoint = "Test",
CallingConvention = CallingConvention.StdCall)]
public static extern int Test();
Why I need the extern “C” ?
The main reason is to prevent the C++ name mangler from mangling the name of the function.
Try exporting it without the
extern "C"and inspect the resulting DLL in Dependency Walker and you will see a quite different name for the exported function.