This is a similar question to this one.
I want to export a simple function from C++, to be called by C# via PInvoke. This is my function definition:
int fnValue()
{
return 42;
}
And this is the export definition in .h file:
__declspec(dllexport) int fnValue();
This is how I PInvoke the function:
[DllImport("WhatDll.dll")]
public static extern int fnValue();
Simple, right? But I got a
System.EntryPointNotFoundException :
Unable to find an entry ‘point named
‘fnValue’ in DLL “WhatDll.dll’
I use dumpbin to check what’s inside WhatDll, and this is what I have:
00000000 characteristics 4CFB5C95
time date stamp Sun Dec 05 17:34:13
2010
0.00 version
1 ordinal base
4 number of functions
4 number of namesordinal hint RVA name
1 2 00011014 ?fnValue@@YAHXZ = @ILT+15(?fnValue@@YAHXZ)
Note that there is some gibberish behind the function name fnValue.
This is pretty puzzling. Any idea?
Try to write