背景:我在.NET中开发了一个Activex控件,但发现它在使用它的各种应用程序中造成了稳定性问题。我从示例应用程序中找到了一系列步骤,下面概述了类似的不稳定性。
我有一个示例Activex控件,它是我从开发中心网站下载的,名为“CSActivex”(http://code.msdn.microsoft.com/windowsdesktop/CSActiveX-b86194f8)。
构建起来相当容易,我只是在VS2010 Express (C#)中加载了这个项目,并将其编译成了一个.dll
然后,我从VS2008 C++创建了一个示例MFC应用程序来建模遗留应用程序(它不使用任何.NET)。目标是基于简单对话框的GUI,它有一个关于的框。
我用regasm注册了csactivex.dll,并将dll复制到VS文件夹中,这样我就可以在设计时插入Activex控件,然后再插入到Debug文件夹,这样可以在运行时找到它。
在设计时,我将CSActivex控件插入到“关于”对话框中,它将毫无意外地出现。在构建dll并将dll复制到Debug文件夹并运行调试会话之后,如果我继续导航到“关于”框,单击控件上的各个位置,关闭“关于”对话框并重复几次,我开始在输出日志中看到有关访问冲突的消息,它开始如下所示:
'CSActivexMFC.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Windows.Forms\63406259e94d5c0ff5b79401dfe113ce\System.Windows.Forms.ni.dll'
'CSActivexMFC.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll'
'CSActivexMFC.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.2600.5581_x-ww_dfbc4fc4\GdiPlus.dll'
'CSActivexMFC.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\Accessibility\11eb4f6606ba01e5128805759121ea6c\Accessibility.ni.dll'
First-chance exception at 0x00000000 in CSActivexMFC.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in CSActivexMFC.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x79f4c2f7 in CSActivexMFC.exe: 0xC0000005: Access violation reading location 0x0000000b.
First-chance exception at 0x79f4c2f7 in CSActivexMFC.exe: 0xC0000005: Access violation reading location 0x0000000b.
虽然它不会在调试器中崩溃,但我不得不认为这是不好的,我有一种感觉,它可能与其他.NET Activex控件的不稳定性有关。如果我能找到解决这个问题的方法,同样的解决方案可能会帮助原来的控制。
我试着打破这个例外,但它似乎发生在几个不同的地方。当我关闭应用程序时,有一个堆栈跟踪如下:
下面的mscorwks.dll!79f4c2f7()帧可能不正确和/或丢失,没有为mscorwks.dll加载符号 mscorwks.dll!79f4c370() mscorwks.dll!79faa91() mscorwks.dll!79faa858() mscorwks.dll!79faa9ad() mscorwks.dll!79faa9d9() mscorwks.dll 7a079480() mscorwks.dll!7a0798e8() mscorwks.dll!7a043f25() 77525834() rpcrt4.dll!77e799f4() !77ef421a() ntdll.dll!7c915239() ntdll.dll!7c91542b() ntdll.dll!7c91534a() ntdll.dll!7c915239() ntdll.dll!7c91542b() ntdll.dll!7c91534a() ntdll.dll!7c915f75() ntdll.dll!7c9155ed() ntdll.dll!7c915ce9() ntdll.dll!7c96f07c() ole32.dll!77600c15() ole32.dll!77600bbf() ole32.dll 7752ac56()ole32.dll ()() ole32.dll!7752b7ab() ()ole32.dll 7752b5e1()ole32.dll 用户32.dll 7e418734()ole32.dll 7752b54e() ()ole32.dll 7752b54e() 7752b54e()ole32.dll 7752f23e() ole32.dll!77557237() mscorwks.dll!79f9e14d() mscorwks.dll!79f9e0b4() mscorwks.dll!79f9e018() mscorwks.dll!79f4c879() mscorwks.dll!79f3bb76() mscoreei.dll!603cc966() mscoreei.dll!603d1f25() mscoree.dll!790186 0x9 () msvcr90d.dll!_crtCorExitProcess(int status=2)第716 C msvcr90d.dll!_crtExitProcess(int status=2)行722 +0x9字节C msvcr90d.dll!doexit(int code=2,int quick=0,( int retcaller=0)行644 + 0x9字节C msvcr90d.dll!退出(int code=2)行412 + 0xd字节C CSActivexMFC.exe!__tmainCRTStartup()行595 C CSActivexMFC.exe!wWinMainCRTStartup()行399 C内核32.dll!7c817077()
我希望以前有人会遇到这样的情况,我在多台机器(家庭和工作中)上遇到了这个问题,至少缩小到了CSActivex不应该做的问题,或者在MFC中遇到了问题。
那么,我的问题是如何使这些样本在不违反访问权限的情况下工作呢?
编辑:
只要打开“关于”窗口并反复关闭它,最终会导致调试器(未处理的异常)崩溃,下面有堆栈跟踪,在我看来,被销毁的对象又被销毁了吗?
First-chance exception at 0x00400003 in CSActivexMFC.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x00400003 in CSActivexMFC.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x003a005c in CSActivexMFC.exe: 0xC0000096: Privileged instruction.
First-chance exception at 0x00460020 in CSActivexMFC.exe: 0xC0000005: Access violation reading location 0x00460020.
First-chance exception at 0x78b6ba1d (mfc90ud.dll) in CSActivexMFC.exe: 0xC0000005: Access violation writing location 0x00000018.
Unhandled exception at 0x78b6ba1d (mfc90ud.dll) in CSActivexMFC.exe: 0xC0000005: Access violation writing location 0x00000018.
mfc90ud.dll!CDataSourceControl::~CDataSourceControl() Line 2431 + 0x2d bytes C++
mfc90ud.dll!CDataSourceControl::`scalar deleting destructor'() + 0x11 bytes C++
mfc90ud.dll!COleControlSite::~COleControlSite() Line 77 + 0x22 bytes C++
mfc90ud.dll!COleControlSite::`scalar deleting destructor'() + 0x11 bytes C++
mfc90ud.dll!COleControlSiteOrWnd::~COleControlSiteOrWnd() Line 161 + 0x24 bytes C++
mfc90ud.dll!COleControlSiteOrWnd::`scalar deleting destructor'() + 0x11 bytes C++
mfc90ud.dll!COleControlContainer::~COleControlContainer() Line 199 + 0x1c bytes C++
mfc90ud.dll!COleControlContainer::`scalar deleting destructor'() + 0x11 bytes C++
mfc90ud.dll!CWnd::OnDestroy() Line 786 + 0x24 bytes C++
mfc90ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0, long lParam=0, long * pResult=0x0012f510) Line 2042 C++
mfc90ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int wParam=0, long lParam=0) Line 1755 + 0x20 bytes C++
mfc90ud.dll!AfxCallWndProc(CWnd * pWnd=0x0012f88c, HWND__ * hWnd=0x002c04fc, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0) Line 240 + 0x1c bytes C++
mfc90ud.dll!AfxWndProc(HWND__ * hWnd=0x002c04fc, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0) Line 403 C++
mfc90ud.dll!AfxWndProcBase(HWND__ * hWnd=0x002c04fc, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0) Line 441 + 0x15 bytes C++
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!7e418816()
mfc90ud.dll!CThreadSlotData::GetThreadValue(int nSlot=6623744) Line 268 C++
user32.dll!7e428eec()
ntdll.dll!7c90e473()
user32.dll!7e42b1a8()
mfc90ud.dll!CWnd::DestroyWindow() Line 1007 + 0xd bytes C++
90909090()
https://stackoverflow.com/questions/11218694
复制相似问题