描述:
做了一个写日志的COM DLL,自己编写测试程序调用均正常但是要在普通DLL中调用却出错
提示为:Unhandled exception in myApp.exe(NTDLL.DLL):0xE06D7363 Microsoft c++ exception
调试时发现在初始化COM组件时就出错了,怎样才能解决?
还有由APP WIZARD生成的REGULAR DLL怎么没有DLLMAIN()函数的但是选择MFC EXTENSION就有这个函数?不是每个DLL都要有这个函数的么?VC把它隐含在哪了?那如果要在DLLMAIN()中进行一些全局变量初始化怎么办?难道要自己写DLLMAIN()函数的?
普通DLL程序部分代码如下:
MyApp.h
...
#import "Logger.tlb" no_namespace//加入日志控件类型库
...
class CMyApp : public CWinApp
{
public:
ILogoutPtr g_pLogout;//定义接口指针
CMyApp();
....
....
}
MyApp.cpp
BOOL CMyApp::InitInstance()
{
// TODO: Add your specialized code here and/or call the base class
// COleObjectFactory::RegisterAll();
if(!AfxOleInit())
{
AfxMessageBox("error init COM!");
return FALSE;
}
// ILogoutPtr g_pLogout("Logger.Logout.1");
g_pLogout=ILogoutPtr("Logger.Logout.1");//初始化日志控件 调试时到这里就出错了,但是在单独编写的日志控件测试程序同样的代码就是正常的!
return CWinApp::InitInstance();
}