I converted this project from VS 2003 to VS 2010.
I get this exception while running it: First-chance exception at 0x00000000 in acad.exe: 0xC0000005: Access violation reading location 0x00000000.
The debugger points to this line: m_saveButton.SetFont(pFont);
If I comment this line out, the same exception occurs on the next line, and so on, as if this line is not really the culprit.
What does this mean?
Any ideas? Thanks!
Note that I’m using Win7 32bit.
This is the stack trace:
|dwgtool.arx!CParamsSheet:nInitDialog() Line 1954||C++|
|mfc90u.dll!CWnd:nWndMsg(unsigned int message=272, unsigned int wParam=398414, long lParam=663540192, long * pResult=0x1b49c65c) Line 1897||C++|
|mfc90u.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=398414, long lParam=663540192) Line 1755 + 0x17 bytes||C++|
|mfc90u.dll!AfxCallWndProc(CWnd * pWnd=0x84c820c4, HWND__ * hWnd=0x0006144c, unsigned int nMsg=272, unsigned int wParam=398414, long lParam=663540192) Line 240 + 0x11 bytes||C++|
|mfc90u.dll!AfxWndProc(HWND__ * hWnd=0x0006144c, unsigned int nMsg=272, unsigned int wParam=398414, long lParam=663540192) Line 402 + 0x10 bytes||C++|
|mfc90u.dll!AfxWndProcBase(HWND__ * hWnd=0x0006144c, unsigned int nMsg=272, unsigned int wParam=398414, long lParam=663540192) Line 441 + 0x16 bytes||C++|
|[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]|
Set your breakpoint at the offending line, then when the breakpoint gets hit, inspect the values of the class members and their contents. Look for unexpected NULL pointer values. For example, if 'this' is NULL you might get the behavior you describe.
Owen, thank you for your feedback.
When the exception occurs, the IDE is pointing at this line of code:
But I'm sure the exception is really at the line before:
m_saveButton.Create(strSave ,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,rect,this,IDC_BUTTON_SAVE); m_saveButton.SetFont(pFont);
As for the null, please see the image of the Autos window at the offending line.
Could the ‘text’ variable cause the exception or could it be the 'm_hIcon'?
Should the ‘text’ variable have a value before reaching this point (before calling the
Sorry, I am not familiar with your code, so I don't know whether text should have a value. You need to use your knowledge of the code to determine what values should be where, then use the tools available in the debugger to determine whether those values are correct. When I'm debugging this type of problem, I set the debugger to break on the exception, then use the disassembly window to determine exactly what instruction caused the exception, then work backward to figure out where things went haywire.
Access a broad range of knowledge to help get the most out of your products and services.