解决 VC2012 ATL 多线程调用 报错:E_UNEXPECTED Catastrophic failure.
2016-03-02 17:12
369 查看
根本原因是在创建“ATL简单对象“时,线程模型默认选择的是“单元”。导致子线程异步调用到主线程函数时,报错“E_UNEXPECTED Catastrophic failure.”
修改方案:
将ATL简单对象的线程模型属性设置为“自由”,具体操作如下:
1. 修改 Ukey.rgs 线程模型声明内存模型为“自由”
2. 修改Ukey.h 类声明多线程支持
保存,重新编译项目。多线程异步调用正常。
修改方案:
将ATL简单对象的线程模型属性设置为“自由”,具体操作如下:
1. 修改 Ukey.rgs 线程模型声明内存模型为“自由”
Ukey.rgs InprocServer32 = s '%MODULE%' { val ThreadingModel = s '<span style="color:#FF0000;">Free</span>' }
2. 修改Ukey.h 类声明多线程支持
class ATL_NO_VTABLE CUkey : <span style="color:#FF0000;">public CComObjectRootEx<CComMultiThreadModel></span>, public CComCoClass<CUkey, &CLSID_Ukey>, public IDispatchImpl<IUkey, &IID_IUkey, &LIBID_ahdmsUkeyLib, /*wMajor =*/ 1, /*wMinor =*/ 0>, public IObjectSafetyImpl<CUkey,INTERFACESAFE_FOR_UNTRUSTED_CALLER> {
保存,重新编译项目。多线程异步调用正常。
相关文章推荐
- 理解assign,copy,retain
- sqoop连接mysql出现Failed to list databases com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
- 76.You need to display the first names of all customers from the CUSTOMERS table that contain the
- pod的SDK报错,Linker command failed with exit code1(use -v to see invocation)
- pod的SDK报错,Linker command failed with exit code1(use -v to see invocation)
- AIX 6.1 异步 I/O 的 配置与性能评估
- 使用RAID进行磁盘管理
- AIX 6.1 异步 I/O 的 配置与性能评估
- studio中install_failed_dexopt 解决
- 环信SDK报错处理方法obtain an updated library from the vendor, or disable bitcode for this target. for archit
- 环信SDK报错处理方法obtain an updated library from the vendor, or disable bitcode for this target. for archit
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift 论文翻译
- io.h头文件下的一些函数 http://blog.csdn.net/babygjx/article/details/5740038
- 设计模式 ( 十二 ) 职责链模式(Chain of Responsibility)(对象行为)
- .NET程序连接OPC Server时出错 对 COM 组件的调用返回了错误 HRESULT E_FAIL
- assign©&ratain, strong&weak, nonatomic
- 人工智能2:智能Agent
- 人工智能1:基本概念
- BIT2014级软件学院程序设计-09 Easier Done Than Said
- 解决INSTALL_FAILED_VERSION_DOWNGRADE