我有一个C#应用程序,我试图将参数发送到C函数.但是,我收到了错误(在主题中提到)
C#应用程序:
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
extern "C" QUERYSEGMENTATION_API int fnmain(char searchc[MAX_LEN_Q])
{
do something...
}
解决方法:
Dependency Walker可以显示从DLL有效导出的函数.您将能够看到您的fnmain是否存在,或者它是_fnmain,或者名称中有C装饰.
标签:c,c-2,visual-c
来源: https://codeday.me/bug/20190621/1250982.html