困扰我好久了 ASSERT(afxCurrentInstanceHandle != NULL)

lustersir 2010-09-14 02:36:12
我在做一个Adobe acrobat下的插件,这个插件编译完后实际就是个.dll文件。
插件里面要用到对话框,所以添加了MFC的支持。
在Adobe acrobat一启动,将要加载这个dll时,出现了一个断言错误
D:\Microsoft Visual Studio 8\VC\atlmfc\include\afxwin1.inl 21行

_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
{ ASSERT(afxCurrentInstanceHandle != NULL);
return afxCurrentInstanceHandle; }

afxCurrentInstanceHandle为空导致了这个错误。
我调试运行,发现还没有运行到DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )呢就出现了这个错误。
我把编译选项_DEBUG 换成 NDEBUG还是会出现。

下面是出错时的调用堆栈:(Template.api就是我编译出的那个dll,只是扩展名不同。)

Template.api!AfxGetInstanceHandle() 行21 + 0x1e 字节 C++
Template.api!AfxRegisterWndClass(unsigned int nClassStyle=0, HICON__ * hCursor=0x00000000, HBRUSH__ * hbrBackground=0x00000000, HICON__ * hIcon=0x00000000) 行1402 + 0x5 字节 C++
Template.api!CXInfoTip::CXInfoTip() 行60 + 0xd 字节 C++
Template.api!`dynamic initializer for 'tip''() 行547 + 0x13 字节 C++
Template.api!_initterm(void (void)* * pfbegin=0x04aac41c, void (void)* * pfend=0x04aac5e0) 行855 C
Template.api!_cinit(int initFloatingPrecision=0) 行293 + 0xf 字节 C
Template.api!_CRT_INIT(void * hDllHandle=0x047f0000, unsigned long dwReason=1, void * lpreserved=0x00000000) 行179 + 0x19 字节 C
Template.api!__DllMainCRTStartup(void * hDllHandle=0x047f0000, unsigned long dwReason=1, void * lpreserved=0x00000000) 行359 + 0x11 字节 C
Template.api!_DllMainCRTStartup(void * hDllHandle=0x047f0000, unsigned long dwReason=1, void * lpreserved=0x00000000) 行328 + 0x11 字节 C
ntdll.dll!7c92118a()
[下面的框架可能不正确和/或缺失,没有为 ntdll.dll 加载符号]
ntdll.dll!7c93bf2a()
ntdll.dll!7c93ca4e()
ntdll.dll!7c93cd4b()
ntdll.dll!7c935c81()
ntdll.dll!7c935508()
ntdll.dll!7c93556d()
kernel32.dll!7c80ef6c()
ntdll.dll!7c932ce6()
ntdll.dll!7c932d1c()
……
...全文
750 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
专属酱油~~ 2012-04-18
  • 打赏
  • 举报
回复 1
能说明白点么
lustersir 2010-09-14
  • 打赏
  • 举报
回复
问题解决了,一个废弃了的全局变量引起的。
初始化CXInfoTip窗口类的一个变量造成的。
全局变量不能适用啊!

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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