debug assertion failed?

Ok here is my problem one day i changed something, i don't know what, and my program now gets this message

Debug assertion failed!
Program:....
File: dlgdata.cpp
Line: 44
What is that?
here is the code at and around that point

HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);
ASSERT(nIDC != -1); // not allowed
HWND hWndCtrl;
COleControlSite* pSite = NULL;
m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if (hWndCtrl == NULL)
{
// Could be a windowless OCX
pSite = m_pDlgWnd->GetOleControlSite(nIDC);
if (pSite == NULL)
{
TRACE(traceAppMsg, 0, "Error: no data exchange control with ID 0x%04X.\n", nIDC);
ASSERT(FALSE);
AfxThrowNotSupportedException();
}
}
m_idLastControl = nIDC;
m_bEditLastControl = FALSE; // not an edit item by default
return hWndCtrl;
}

Thanks for the help

[934 byte] By [surferboy] at [2007-12-16]
# 1
Looks like the ASSERT failure is outside of your source code. Here's what I would do under the circumstances: start the application in debug mode, wait for the debug assertion to occur, then check the Call Stack window in Visual Studio (you may need to activate this; in my configuration it's in a little tabbed window to the lower right). The call stack lists every function call that your application has made, in reverse order, so start at the top and read downwards until you recognize the most recent function call within your code (not windows code). Double-click on it and you'll be taken to the location in your code where it was called. Usually the problem is in this vicinity, or it can be traced backward from here. The call stack has made my life lot's easier :)
Algorimancer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 2
ok. the problem as i see it is you have checks to see if your call to GetDlgItem failed.. but after the checks you change the m_idLastControl as if the function succeeded and you return the hWndCtrl as if the function succeeded. I think that if you check the return of this function to see if it has a valid HWND you should get it working.
Hyresse at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 3
i was unable to find the call stack in the menu anywhere but i am new at this so please forgive my ignorance. i did get the debug if it wouldhelp.
'demo.exe': Loaded 'C:\Documents and Settings\wburge\Desktop\demotest\demo\Debug\demo.exe', Symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\Documents and Settings\wburge\Desktop\demotest\demo\PSL_SerialDLL.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\mfc71d.dll', Symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msvcr71d.dll', Symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msvcp71d.dll', Symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\MFC71ENU.DLL', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\Program Files\Stardock\ObjectDock\DockShellHook.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\clbcatq.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\comres.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msi.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\cwui.ocx', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\mfc42.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\olepro32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msvcp60.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded.
'demo.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', No symbols loaded.
'demo.exe': Unloaded 'C:\WINDOWS\system32\msimg32.dll'
'demo.exe': Loaded 'C:\WINDOWS\system32\xpsp2res.dll', No symbols loaded.
Error: no data exchange control with ID 0x03EE.
'demo.exe': Loaded 'C:\Program Files\Yahoo!\Messenger\idle.dll', No symbols loaded.
'demo.exe': Loaded 'C:\Program Files\Yahoo!\Messenger\msvcr71.dll', No symbols loaded.
Unhandled exception at 0x7c25f2d1 (mfc71d.dll) in demo.exe: User breakpoint.
First-chance exception at 0x7c81eb33 in demo.exe: Microsoft C++ exception: CNotSupportedException @ 0x0012f1e0.
Warning: UpdateData failed during dialog init.
'demo.exe': Unloaded 'C:\WINDOWS\system32\cwui.ocx'
'demo.exe': Unloaded 'C:\WINDOWS\system32\msvcp60.dll'
'demo.exe': Unloaded 'C:\WINDOWS\system32\shell32.dll'
'demo.exe': Unloaded 'C:\WINDOWS\system32\mfc42.dll'
The thread 'Win32 Thread' (0x9f0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xbf8) has exited with code 0 (0x0).
The program '[1140] demo.exe: Native' has exited with code 0 (0x0).

Thanks again.

surferboy at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 4
I didn't see the getdlgitem? maybe im just stupid, im down with that but let me know if you have any other suggestions and maybe an example next time.
Thanks
surferboy at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 5
ok i don't know if this means anything but i was playing with the debug to see what i could find and i got this error message.

"Unhandled exception at 0x7c25f2d1 (mfc71d.dll) in demo.exe: User breakpoint."

What is that. there is no breakpoint set. so why does it think that thier is?

Thanks

surferboy at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 6

You can learn about the call stack by checking the index for "call stack window, troubleshooting". From this:

To display the Call Stack window (in break mode or run mode)

  • From the Debug menu, choose Windows and click Call Stack.

Algorimancer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 7
surferboy wrote:
Debug assertion failed!

Program:....
File: dlgdata.cpp
Line: 44

What is that?

A debug assertion is supposed to help you debug your program by causing it to blow up when some particular expression (the assertion) is false. That way you get to break into the debugger where the bad thing is happening and can figure out how and why it happened.

For example, at the start of the code you quoted is this...

HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);

If you were to call Prepare and pass in a zero value for nIDC then the expression within the ASSERT macro would be false and a debug assertion exception would occur.

Line 44 of dlgdata.cpp (in the April 2005 Platform SDK at least) is that AfxThrowNotSupportedException(); statement, but I think the line number is off by one (or possibly you are using a different version of dlgdata.cppp).

Getting to this code means both the hWndCtrl associated with nIDC and the pSite retrieved by calling GetOleControlSite were both NULL. Apparently that's a bad thing so the error handling logic calls ASSERT (FALSE) to throw an Assertion failure in debug cases and then calls AfxThrowNotSupportedException to throw a not supported exception in non-debug cases (becaiuse ASSERT macros have no effect in non debug builds)

If you are calling Prepare youself, look at the nIDC value you are passing in, it must be bad somehow. If prepare is being called for you, or as a consequence of your calling some other method then you need to figure out why the nIDC being passed to Prepare is bad.

"Unhandled exception at 0x7c25f2d1 (mfc71d.dll) in demo.exe: User breakpoint."

What is that. there is no breakpoint set. so why does it think that thier is?

The Assertion failure is a breakpoint. The ASERT macro looks like this...


#define ASSERT(f) (void) ((f) || !AfxAssertFailedLine(THIS_FILE, __LINE__) || (AfxDebugBreak(), 0))
The AfxDebugBreak () call causes a breakpoint to occur.

FrankBoyne at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 8

I'm having the same problem. What I did to mess things up (i think), was I copied some resources from another instance of visual studio in my current project. visual studio has been broken this way since since at least VC++ 4.0 (maybe 2.0 even)...I just forgot Sad

Anyway, your resources are probably messed up...check resource.h. This is why GetDlgItem is failing...the resource ID passed in is bad. PrepareCtrl first trys to get handle to control, if it can't it expect its to be ole control.

eDevMachine at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...