"无法找到DLL&QUOT名为[功能]切入点; (C ++到C#类型转换) [英] "Unable to find an entry point named [function] in dll" (c++ to c# type conversion)
问题描述
我有一个来自第三方,这是用C ++编写的DLL。
下面是来自该dll文件的一些信息:
I have a dll which comes from a third party, which was written in C++. Here is some information that comes from the dll documentation:
//start documentation
RECO_DATA{
wchar_t Surname[200];
wchar_t Firstname[200];
}
说明:
数据结构,用于接收功能的结果。所有函数的结果将是
存储为统一code(UTF-8)。
Description: Data structure for receiving the function result. All function result will be stored as Unicode (UTF-8).
方法:
bool recoCHN_P_Name(char *imgPath,RECO_DATA *o_data);
输入:
char * imgPath
图像位置的这种情况的完整路径
功能识别
the full path of the image location for this function to recognize
RECO_DATA * o_data
用于接收功能
数据对象
结果。
函数返回:
真要是成功,否则为false会回来。
data object for receiving the function result. Function return: True if Success, otherwise false will return.
//end documentation
我想从我的C#应用程序调用recoCHN_P_Name。为此,我想出了这个code:
I am trying to call the recoCHN_P_Name from my C# application. To this end, I came up with this code:
在code导入的DLL:
The code to import the dll:
public class cnOCRsdk
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECO_DATA{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=200)]
public string FirstName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 200)]
public string Surname;
}
[DllImport(@"cnOCRsdk.dll", EntryPoint="recoCHN_P_Name")]
public static extern bool recoCHN_P_Name(byte[] imgPath, RECO_DATA o_data);
}
在code调用的函数:
The code to call the function:
cnOCRsdk.RECO_DATA recoData = new cnOCRsdk.RECO_DATA();
string path = @"C:\WINDOWS\twain_32\twainrgb.bmp";
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] bytes = encoding.GetBytes(path);
bool res = cnOCRsdk.recoCHN_P_Name(bytes, recoData);
和我得到错误的是
无法找到DLL'cnOCRsdk.dll名为'recoCHN_P_Name切入点。
我怀疑我是从C ++转换一个类型到C#有一个错误。但究竟哪里...?
And the error I'm getting is ""Unable to find an entry point named 'recoCHN_P_Name' in DLL 'cnOCRsdk.dll'." I'm suspecting that I'm having an error in converting a type from C++ to C#. But where exactly ... ?
推荐答案
首先确保该功能实际出口:
First make sure the function is actually exported:
在Visual Studio命令提示符下,使用 DUMPBIN /出口whatever.dll
In the Visual Studio Command Prompt, use dumpbin /exports whatever.dll
这篇关于"无法找到DLL&QUOT名为[功能]切入点; (C ++到C#类型转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!