异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。在线等。。谢谢

飞飞234 2015-10-16 03:04:23
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 派生。

不加,也有错误,好像是内存读写错误的问题
...全文
389 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Poopaye 2015-10-16
  • 打赏
  • 举报
回复
啊,你释放一个int是几个意思?

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧