I wrote a DLL in dev C ++. The DLL name is "DllMain.dll" and contains two functions: HelloWorld and ShowMe . The header file is as follows:
DLLIMPORT void HelloWorld(); DLLIMPORT void ShowMe();
And the source file is as follows:
DLLIMPORT void HelloWorld () { MessageBox (0, "Hello World from DLL!\n", "Hi",MB_ICONINFORMATION); } DLLIMPORT void ShowMe() { MessageBox (0, "How are u?", "Hi", MB_ICONINFORMATION); }
I compile the code in a DLL and call two functions from C #. C # code is as follows:
[DllImport("DllMain.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void HelloWorld(); [DllImport("DllMain.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void ShowMe();
When I call the "HelloWorld" function, it works well and a messageBox pops up, but when I call the ShowMe function, an EntryPointNotFoundException . How to avoid this exception? Do I need to add extern "C" to the header file?
source share