MSXML2 :: IXMLDOMDocumentPtr-> gt;时,Internet Explorer崩溃. Release()被称为 [英] Internet Explorer crashes when MSXML2::IXMLDOMDocumentPtr -> Release() is called
问题描述
我正在使用Visual Studio 2008在C ++(ATL 9)中创建一个外壳扩展.外壳扩展在模块类中创建一个全局MSXML2 :: IXMLDOMDocumentPtr对象m_XmlDoc.然后,所有类在扩展名中都使用此m_XmlDoc来读取xml文档.
I am creating a shell extension in C++ (ATL 9) using Visual Studio 2008. The Shell Extension creates a global MSXML2::IXMLDOMDocumentPtr object m_XmlDoc in the module class. This m_XmlDoc is then used in the extension by all classes to read xml document.
我面临的问题是Internet Explorer.当Shell Extension处于活动状态并且我打开/关闭Internet Explorer时,出现调试对话框,IE崩溃.错误消息显示"iexplore.exe中0x6aac30f1的未处理异常:0xC0000005:访问冲突读取位置0x03050970." 当我在消息窗口上单击中断"时,它带我到COM Smart Pointer的释放"方法,并且错误似乎在 m_pInterface-> Release();
The problem that I am facing is with Internet explorer. When the Shell Extension is active and I open/close internet explorer, I get a debug dialog and IE crashes. The error message says "Unhandled exception at 0x6aac30f1 in iexplore.exe: 0xC0000005: Access violation reading location 0x03050970." When I click "break" on the message window, It takes me to the "Release" method of COM Smart Pointer and the error seems to be on m_pInterface->Release();
此调用是从Module的析构函数进行的,并且m_pInterface的值也不为NULL.我认为也许互联网浏览器正在使用XML DOM,并且对Release的调用在其中造成了一些问题.
This call was made from Module's destructor and also the value of m_pInterface is not NULL. I think maybe internet explorer is using the XML DOM and the call to Release creates some problem in it.
MSXML2::IXMLDOMDocumentPtr m_XmlDoc;
In _AtlModule.Init() method
::CoInitialize(NULL);
m_XmlDoc.CreateInstance(MSXML2::CLSID_DOMDocument40);
dll主代码:
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
::CoInitialize(NULL);
if (dwReason == DLL_PROCESS_ATTACH)
{
_AtlModule.Init();
CreateImageLists();
::DisableThreadLibraryCalls(hInstance);
}
hInstance;
return _AtlModule.DllMain(dwReason, lpReserved);
}
推荐答案
问题是由于用于XmlDomDocument的COM智能指针.我将其更改为普通指针,即使在Vista中也可以正常工作.
The problem was because of the COM Smart Pointer used for XmlDomDocument. I changed it to a normal pointer and it is working fine even in Vista.
在XP和Vista中,此问题的行为不同.在XP中,关闭Internet Explorer时遇到未处理的异常.在Vista中,我无法浏览虚拟驱动器.
This problem has a different behaviour in XP and Vista. In XP, I was getting an unhandled exception when I closed Internet Explorer. In Vista, I was not able to browse the virtual drive.
这篇关于MSXML2 :: IXMLDOMDocumentPtr-> gt;时,Internet Explorer崩溃. Release()被称为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!