我從我試圖參數發送到C++功能的C#應用程序。不過,我收到錯誤(在主題中提到)無法找到入口點DLL
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...
}
QUERYSEGMENTATION_API *明確*在您的C++項目中定義爲__declspec(dllexport),並且您可以在Dependency Walker中打開MyApplication.dll時看到導出的函數(depends.exe是Visual Studio工具,以防您不確定)? – adelphus 2012-02-22 10:21:15