Reslease 模式下运行正常
调到Debug模式断点跟踪的话 出问题了
问题出在 _CrtDbgReport函数(...\VC98\MFC\SRC\AFXASERT.CPP中调用的)
网上查了一下 很多说是多线程设置问题
看了一下 多线程的设置已经设置好了
出现的问题是 弹出 Micorsoft Visual C++ Debug Library对话框错误提示: Debug Assertion Failed!File: ...\Multimon\Monitors.cppLine: 112不懂了,这是什么问题呢? 怎么解决?
调到Debug模式断点跟踪的话 出问题了
问题出在 _CrtDbgReport函数(...\VC98\MFC\SRC\AFXASERT.CPP中调用的)
网上查了一下 很多说是多线程设置问题
看了一下 多线程的设置已经设置好了
出现的问题是 弹出 Micorsoft Visual C++ Debug Library对话框错误提示: Debug Assertion Failed!File: ...\Multimon\Monitors.cppLine: 112不懂了,这是什么问题呢? 怎么解决?
如何查堆栈?
感觉不像是代码的问题 如果是代码的问题那为什么在Reslease 模式下运行正常呢?
在库函数中出错
BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName,int nLine)
{
MSG msg;
BOOL bQuit=PeekMessage(&msg,Null,WM_QUIT,PM_REMOVE);
问题行:
--------
BOOL bResult=_CrtDbgReport(_CRT_ASSERT,lpszFileName,nLine,NULL,NULL);
--------
}
{
#if if _MFC_VER>=0x0700
ASSERT(index>=0 && Index < m_MonitorArray.GetCount());
#else
ASSERT(index>=0 && Index < m_MonitorArray.GetSize()); // *由此进入*
#endif
CMonitor * pMonitor = (CMonitor*)m_MonitorArray.GetAt(index);
return *pMonitor;
}
再之前是 CMonitor monitor= g_monitors.GetMonitor(nIndex);
只有调试的时候才出这个错误提示另,多谢你了,这两天都是你帮忙,呵呵
我刚接触VC 以后还要请你多多指教啊
我看了一下nIndex是1 没有超出范围这两句什么意思:
#define VERIFY(f) ASSERT(f)
ASSERT(index>=0 && Index < m_MonitorArray.GetSize()); 跟进后进入下面的方法,该方法有两个参数 为什么调用的时候写成index>=0 && Index < m_MonitorArray.GetSize()呢?
BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName,int nLine)
{
MSG msg;
BOOL bQuit=PeekMessage(&msg,Null,WM_QUIT,PM_REMOVE);
问题行:
--------
BOOL bResult=_CrtDbgReport(_CRT_ASSERT,lpszFileName,nLine,NULL,NULL);
--------
}
DEBUG和RELEASE在执行逻辑上没有区别,在内存分配方式是不同的,可能是这个原因看看编译选项吧http://www.yichao.info/2009/09/vc-debug-release-%E7%BC%96%E8%AF%91%E9%93%BE%E6%8E%A5%E9%80%89%E9%A1%B9%E5%B7%AE%E5%BC%82%E5%92%8C%E5%8C%BA%E5%88%AB.htmlhttp://bbs.lierda.com/archive/index.php/t-56365.html
CMonitors::GetMonitor(const int 1) line 112 + 43 bytes
InitAllBmp() line 462 + 21 bytes
Init_App(HWND__ * 0x000f0514, CWnd * 0x0012fc44 {CBLMainDlg hWnd=???}) line 420 + 5 bytes
CBLMainDlg::OnInitDialog() line 306 + 16 bytes
AfxDlgProc(HWND__ * 0x000f0514, unsigned int 272, unsigned int 918858, unsigned int 918858) line 35 + 14 bytes
USER32! 77d18734()
USER32! 77d2413c()
USER32! 77d23b30()
USER32! 77d3e599()
USER32! 77d18734()
USER32! 77d18816()
USER32! 77d2a013()
USER32! 77d2a998()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 918858, long 0) line 1011 + 32 bytes
CWnd::Default() line 258
CDialog::HandleInitDialog(unsigned int 918858, unsigned int 918858) line 624 + 8 bytes
CWnd::OnWndMsg(unsigned int 272, unsigned int 918858, long 0, long * 0x0012f86c) line 1826 + 17 bytes
CWnd::WindowProc(unsigned int 272, unsigned int 918858, long 0) line 1596 + 30 bytes
AfxCallWndProc(CWnd * 0x0012fc44 {CBLMainDlg hWnd=???}, HWND__ * 0x000f0514, unsigned int 272, unsigned int 918858, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x000f0514, unsigned int 272, unsigned int 918858, long 0) line 379
USER32! 77d18734()
USER32! 77d18816()
USER32! 77d2927b()
USER32! 77d2651a()
USER32! 77d2683e()
USER32! 77d39b43()
CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x00186c70, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
CDialog::DoModal() line 531 + 32 bytes
CBLMainApp::InitInstance() line 73 + 11 bytes
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00141f0b, int 1) line 39 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00141f0b, int 1) line 30
WinMainCRTStartup() line 198 + 54 bytes
KERNEL32! 7c817067()