“无法在dll中找到名为[function]的入口点” (c ++到c#类型的转换) [英] "Unable to find an entry point named [function] in dll" (c++ to c# type conversion)

查看:543
本文介绍了“无法在dll中找到名为[function]的入口点” (c ++到c#类型的转换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自第三方的dll,它是用C ++编写的。
这里有一些来自dll文档的信息:

  //启动文档

RECO_DATA {
wchar_t姓[200];
wchar_t名字[200];
}

说明:
接收函数结果的数据结构。所有函数结果将以$ Unicode(UTF-8)的形式存储



方法:

  bool recoCHN_P_Name(char * imgPath,RECO_DATA * o_data); 

输入:

 code> char * imgPath 


的图像位置的完整路径功能识别

  RECO_DATA * o_data 

数据对象,用于接收函数
结果。
函数return:
如果Success,否则为false,则返回true。

  // end documentation 

我正在尝试从C#应用程序调用recoCHN_P_Name。为此,我想出了这个代码:



导入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);
}

调用函数的代码:

  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);

我得到的错误是
无法找到一个名为cnOCRsdk.dll中的recoCHN_P_Name。
我怀疑我将一个类型从C ++转换为C#时出错,但是在哪里?$ / $ b

解决方案

首先确保该函数实际导出:



在Visual Studio命令提示符下,使用 dumpbin / exports whatever.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];
}

Description: Data structure for receiving the function result. All function result will be stored as Unicode (UTF-8).

Method:

bool recoCHN_P_Name(char *imgPath,RECO_DATA *o_data);

Input:

char * imgPath

the full path of the image location for this function to recognize

RECO_DATA * o_data

data object for receiving the function result. Function return: True if Success, otherwise false will return.

//end documentation

I am trying to call the recoCHN_P_Name from my C# application. To this end, I came up with this code:

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);
}

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);

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:

In the Visual Studio Command Prompt, use dumpbin /exports whatever.dll

这篇关于“无法在dll中找到名为[function]的入口点” (c ++到c#类型的转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆