Could not find entry point in DLL

I have a C # application from which I am trying to send a parameter to a C ++ function. However, I get an error (mentioned in the topic)

C # application:

static class SegmentationFunctions { [DllImport("MyApplication.dll", EntryPoint = "fnmain", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int fnmain(string search); } } public partial class MainWindow:Window { public MainWindow() { InitializeComponent(); string search = "test string here"; int scommand = SegmentationFunctions.fnmain(search); } 

C ++ file.h

 extern "C" QUERYSEGMENTATION_API int fnmain(char query[MAX_Q_LEN]); 

C ++. Cpp file

 extern "C" QUERYSEGMENTATION_API int fnmain(char searchc[MAX_LEN_Q]) { do something... } 
+4
source share
2 answers

Dependency Walker can show you which functions are exported efficiently from a DLL. You can see if your fnmain at all, or is it _fnmain instead, or has a C ++ decoration in its name.

+5
source

Note that by default, visual studio will not copy your own output to the same folder as your managed output.

manually copy your own output to the managed assembly folder and try again - if this is your problem, you need to change the C ++ assembly settings to set the destination folder in the same way as the managed application folder.

Your code is correct - as long as the QUERYSEGMENTATION_API macro is defined correctly and your dll is actually built as "MyApplication.dll"

I would manually execute the executable from the file system - make sure that the latest exe and dll are in the same folder, and if it does not work, run the depend.exe file to understand this.

0
source

Source: https://habr.com/ru/post/1397770/


All Articles