WTL工程中出现运行“Did you forget to pass the LIBID to CComModule::Init”的解决方法

来源:互联网 发布:原生js实现加载更多 编辑:程序博客网 时间:2024/06/06 01:09

 我在使用VS2005开发WTL项目的时候,在运行的时候出现一个ALERT提示,提示内容如下:

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: e:/project/ietools/shinedoo/shinedoo/Debug/shinedoo.exe
File: d:/program files/microsoft visual studio 8/vc/atlmfc/include/atlcom.h
Line: 3751

Expression: !InlineIsEqualGUID(*m_plibid, GUID_NULL) && "Did you forget to pass the LIBID to CComModule::Init?"

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.


问题原因:


我们从提示的语句中很容易看到,这是一个GUID_NULL造成的错误。所以我检查代码之后,是工程模块加载方法CComModule::Init需要三个参数,第三个参数GUID如果为默认的NULL,编译通过,但是运行的时候出现了以上的一个ASERT提示,我们找到调用这个的地方,是在winmain(_tWinMain)函数调用的。

 

解决方法:
在winmain(_tWinMain)中找到如下代码

 

hRes = _Module.Init(NULL, hInstance);

 

修改成

 

GUID guid;
hRes = _Module.Init(NULL, hInstance, &guid);

 

修改后,编译通过,运行成功!

原创粉丝点击