I have written a DLL in dev C++. The DLL's name is "DllMain.dll" and it contains two functions: HelloWorld and ShowMe. The header file looks like this:
DLLIMPORT void HelloWorld(); DLLIMPORT void ShowMe(); And the source file looks like this:
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 into a DLL and call the two functions from C#. The C# code looks like this:
[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 function "HelloWorld" it runs well and pops up a messageBox, but when I call the function ShowMe an EntryPointNotFoundException occurs. How do I avoid this exception? Do I need to add extern "C" in the header file?
CallingConvention.StdCall.