c#调用c++.dll中函数参数问题,急求!!!泪奔~~~~~
k7ta 2008-01-07 04:25:02 在c#中调用dll中方法,目的是要得到struct数组中的数据
dll中函数签名如下:
[System.Runtime.InteropServices.DllImport("XXXXX.dll")]
public static extern char Test(byte[] ImBuf, int nr, int nc, out int nResult, LPRRecogRlt[] fwOcrRlt, int XXX);
其中LPRRecogRlt数据结构如下:
public struct LPRRecogRlt
{
public int ChLen ;
public char[] Code;
public int[] Score;
public int Type;
public int Color;
public int XLeft;
public int XRight;
public int YTop;
public int YBottom;
}
我的调用如下:
LPRRecogRlt[] fwOcrRlt = new LPRRecogRlt[5];
//初始化一些数据,不重要
for (int t = 0; t < fwOcrRlt.Length; t++)
{
fwOcrRlt[t].ChLen = 0;
fwOcrRlt[t].Type = 0;
fwOcrRlt[t].Color = 1;
fwOcrRlt[t].XLeft = 10;
fwOcrRlt[t].XRight = 10;
fwOcrRlt[t].YBottom = 20;
fwOcrRlt[t].YTop = 20;
fwOcrRlt[t].Code = new char[12];
fwOcrRlt[t].Score = new int[12];
}
//******************************
char result = Test(data, test.Height / 2, test.Width, out nresult, fwOcrRlt, 1);
运行是有如下问题:
未处理的异常: System.ArgumentException: 参数不正确。 (异常来自 HRESULT:0x800700
57 (E_INVALIDARG))
在 jpegtest.DLLMethod.FenWei_Car_Recog(Byte[] ImBuf, Int32 nr, Int32 nc, Int3
2& nResult, LPRRecogRlt[] fwOcrRlt, Int32 CarIndex)
在 jpegtest.testCarRecognition.testRec() 位置 D:\code\StationManagementSystem
\jpegtest\testCarRecognition.cs:行号 39
在 jpegtest.testCarRecognition.Main() 位置 D:\code\StationManagementSystem\jp
egtest\testCarRecognition.cs:行号 66
请按任意键继续. . .
求教各位大侠~~~,泪奔中