异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。在线等。。谢谢
public int GetSingleResult(IntPtr pImage, int iLength, out string plate, out int color, out int plateX, out int plateY, out int plateWidth, out int plateHeight)
{
int num5;
try
{
int num = 1;
int cb = Marshal.SizeOf(typeof(CTVPlateRec.PIC_RESULTEX));
IntPtr ptr = Marshal.AllocHGlobal(cb);
Marshal.ReleaseComObject(cb);
int iImageWidth = 0;
int iImageHight = 0;
num = CTVPlateRec.CentrVideo_GetPicResult(pImage, iLength, ref iImageWidth, ref iImageHight, ptr);
CTVPlateRec.PIC_RESULTEX pic_resultex = (CTVPlateRec.PIC_RESULTEX) Marshal.PtrToStructure(ptr, typeof(CTVPlateRec.PIC_RESULTEX));
plate = pic_resultex.szPlateString;
color = pic_resultex.carColor;
plateHeight = pic_resultex.sPlateRect.bottom - pic_resultex.sPlateRect.top;
plateWidth = pic_resultex.sPlateRect.right - pic_resultex.sPlateRect.left;
plateX = pic_resultex.sPlateRect.left;
plateY = iImageHight - pic_resultex.sPlateRect.bottom;
log.Debug("车牌识别返回值:" + num);
log.Debug("车牌识别结果:" + pic_resultex.szPlateString);
Marshal.FreeHGlobal(ptr);
num5 = num;
}
catch (Exception)
{
log.Error("车牌识别错误");
throw;
}
return num5;
其中 Marshal.ReleaseComObject(cb); 这句加了 是异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。
不加,也有错误,好像是内存读写错误的问题
{
int num5;
try
{
int num = 1;
int cb = Marshal.SizeOf(typeof(CTVPlateRec.PIC_RESULTEX));
IntPtr ptr = Marshal.AllocHGlobal(cb);
Marshal.ReleaseComObject(cb);
int iImageWidth = 0;
int iImageHight = 0;
num = CTVPlateRec.CentrVideo_GetPicResult(pImage, iLength, ref iImageWidth, ref iImageHight, ptr);
CTVPlateRec.PIC_RESULTEX pic_resultex = (CTVPlateRec.PIC_RESULTEX) Marshal.PtrToStructure(ptr, typeof(CTVPlateRec.PIC_RESULTEX));
plate = pic_resultex.szPlateString;
color = pic_resultex.carColor;
plateHeight = pic_resultex.sPlateRect.bottom - pic_resultex.sPlateRect.top;
plateWidth = pic_resultex.sPlateRect.right - pic_resultex.sPlateRect.left;
plateX = pic_resultex.sPlateRect.left;
plateY = iImageHight - pic_resultex.sPlateRect.bottom;
log.Debug("车牌识别返回值:" + num);
log.Debug("车牌识别结果:" + pic_resultex.szPlateString);
Marshal.FreeHGlobal(ptr);
num5 = num;
}
catch (Exception)
{
log.Error("车牌识别错误");
throw;
}
return num5;
其中 Marshal.ReleaseComObject(cb); 这句加了 是异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。
不加,也有错误,好像是内存读写错误的问题
...全文
相关推荐
delphi调用VBA的Find_delphi调用VBA的Find_vba调用delphi_
delphi调用VBA的Find,可以通过这种方法,调用大部分的VBA的函数,例子简单,可拓展性很强
VBNET.InheritCOM.rar_VB6.0 net dll_vb.net vb6 activex d
在VB.NET里继承现有的COM(VB6.0生成的ActiveX dll)中的类
jacob的API,很详细
此API是以网页格式展现,大家可以参考里面的函数。很有帮助(自带的API 英文)
用Delphi控制Excel的数据
用Delphi控制Excel的数据
C# 互操作(Interop)实例
C# 互操作(Interop)实例 演示C#程序如何和非托管COM元件交互


