单元测试非ApartmentThreaded COM对象时,QTAgent32.exe挂起 [英] QTAgent32.exe hang when unit testing non-ApartmentThreaded COM objects

查看:77
本文介绍了单元测试非ApartmentThreaded COM对象时,QTAgent32.exe挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对COM对象运行单元测试时遇到问题.我已经能够制作出最低限度的复制场景,如下所示:

I am having problems running unit tests on a COM object.  I have been able to craft a minimal reproduction scenario as follows:

安装VS2010 Professional

Install VS2010 Professional

创建新的解决方案

添加ATL项目

使用两者"或自由"线程模型创建ATL简单对象

Create an ATL Simple Object with either 'Both' or 'Free' Thread model

将C#或C ++/CLI测试项目添加到解决方案中

Add a C# or C++/CLI test project to the solution

构建解决方案

将对COM对象的引用(来自ATL项目)添加到单元测试项目中.

Add a reference to the COM object (from the ATL project) to the unit test project.

在单元测试主体中,调用COM对象的构造函数. (var a = new COMLib.COM())

In the unit test body, call the constructor of the COM object. (var a = new COMLib.COM())

运行解决方案中的所有测试

Run all tests in solution

清洁溶液

预期结果:清理成功

实际结果:Clean发出警告,提示它无法删除COM dll-这是因为QTAgent32.exe仍然具有它的句柄.  将ATL Simple对象更改为Apartment线程模型可解决此问题.

Actual Result: Clean produces a warning that it cannot delete the COM dll - this is because QTAgent32.exe still has a handle to it.  Changing the ATL Simple object to Apartment thread model fixes the issue.

推荐答案

您好,NCrouther,

感谢您在MSDN论坛中发帖.

根据您的描述,您正在使用ATL项目和单元测试.我不是ATL的专家,所以我不太确定您的情况是什么.你能分享 我们一个解决此问题的简单示例?
请附加您的ATL项目和测试项目,您可以将其上传到Sky Drive,然后在您的文章中共享下载链接.

According to your description, you are working with ATL project and unit test. I am not an expert of ATL, so I’m not very sure what your scenario is. Could you share us a simple sample for resolving this issue?
Please attach your ATL project and your test project, you can upload it to the sky drive, and then share the download link in your post.

最好的问候,


这篇关于单元测试非ApartmentThreaded COM对象时,QTAgent32.exe挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆