想调用指昂的指纹系统的PC端匹配的API,
API说明如下:
1: Match two character file on PC
int WINAPI Match2Fp(unsigned char* Src,unsigned char* Dst);
Parameter: Src: source character file buffer.
Dst: destination character file buffer.
Return: function return a score of one matching. Basicly , Should the number be equal or above 50, that indicates successful matching. And the higher the number, the more precise the matching.
用C++调用该API已成功,现想用C#调用,调用代码如下:
[DllImport("ARTH_DLL.dll")]
static extern int Match2Fp(ref byte[] Src, ref byte[] Dst); 出现异常,未处理BadImageFormatException.试图加载格式不正确的程序。(异常来自 HRESULT:0x8007000B)网上查了,好多答案说是,因为dll文件是在64位机下编译的,而开发环境是32位机。我的开发环境是32位的,用VC调用也是在此机上实现的。试了网友的解决的方法未能解决,因而我想这个原因应该可以排除。
API说明如下:
1: Match two character file on PC
int WINAPI Match2Fp(unsigned char* Src,unsigned char* Dst);
Parameter: Src: source character file buffer.
Dst: destination character file buffer.
Return: function return a score of one matching. Basicly , Should the number be equal or above 50, that indicates successful matching. And the higher the number, the more precise the matching.
用C++调用该API已成功,现想用C#调用,调用代码如下:
[DllImport("ARTH_DLL.dll")]
static extern int Match2Fp(ref byte[] Src, ref byte[] Dst); 出现异常,未处理BadImageFormatException.试图加载格式不正确的程序。(异常来自 HRESULT:0x8007000B)网上查了,好多答案说是,因为dll文件是在64位机下编译的,而开发环境是32位机。我的开发环境是32位的,用VC调用也是在此机上实现的。试了网友的解决的方法未能解决,因而我想这个原因应该可以排除。
[DllImport("ARTH_DLL.dll")]
static extern int Match2Fp(byte[] Src, byte[] Dst);
http://topic.csdn.net/u/20091124/21/dabd5228-514e-4c5b-a794-aae11f41dab5.html
项目设置 - 编译 - 目标平台
选择"X86",而不是"Any CPU"面向Any CPU的C#程序,在X64上就会以64bit方式运行,也就会尝试着加载64bit的连接库。
这是如果dll是32位时候,就会抛出BadImageFormatException异常。
[DllImport("ARTH_DLL.dll")]
static extern int Match2Fp(byte[] Src, byte[] Dst);
unsigned char* [MarshalAs(UnmanagedType.LPArray)]byte[](Intptr)
http://topic.csdn.net/u/20091124/21/dabd5228-514e-4c5b-a794-aae11f41dab5.html
不是参数问题,不是32位,64位问题。我在控制端应用程序测试成功了。但是windows应用程序就是会报这错误。有哪位高人知道到底是为什么啊。
[DllImport("ARTH_DLL.dll")]
static extern int Match2Fp(byte[] Src, byte[] Dst);