加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

未处理COMException(转载)

(2009-03-24 22:01:38)
标签:

windows

mobile

透明按钮

comexception

it

分类: 移动平台开发

在前一篇文章中介绍了C#透明按钮的实现,但是实验室其他人反应会出现未处理COMException,晚上把自己手头上任务完成之后,就想看看到底怎么回事,参考网上一篇文章的介绍,修改了一下源文件,测试了一下到现在为止没发现什么问题,但具体情况还有待检验,修改方法如下:

参考:http://www.codeplex.com/alphamobilecontrols/WorkItem/View.aspx?WorkItemId=3720

 

 In IImagingFactory.cs, replace:
// We need the MarshalAs attribute here to keep COM interop from sending the buffer down as 
 uint CreateImageFromBuffer([MarshalAs(UnmanagedType.LPArray)] byte[] buffer, uint size, BufferDisposalFlag disposalFlag, out IImage image);

With:
uint CreateImageFromBuffer(IntPtr buffer, uint size, BufferDisposalFlag disposalFlag, out IImage image);

 

 

In AlphaImage.cs add this in the top of the file:
using System.Runtime.InteropServices;
And replace:
factory.CreateImageFromBuffer(pbBuf, cbBuf, BufferDisposalFlag.BufferDisposalFlagNone, out alphaImage._image);


With:
// Copy stream data into an unmanaged global buffer that will be freed by the factory once
// note that we cannot pass pbBuf directly since it might be moved around or freed by the 
  IntPtr p = Marshal.AllocHGlobal((int)cbBuf);
  Marshal.Copy(pbBuf, 0, p, (int)cbBuf);
  factory.CreateImageFromBuffer(p, cbBuf, BufferDisposalFlag.BufferDisposalFlagGlobalFree, out alphaImage._image);

 

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有