Solved

MFC  - debug assertion failed error

Posted on 2007-03-19
8
2,460 Views
Last Modified: 2013-11-26
Hello,
My MFC project was working ok. I made a change to a line of code and it then started giving me a debug assertion failed error! It points to the ASSERT ( FALSE) line of  this funtion in dlgData.cpp
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;
}


Does anyone know what would cause this error and what should I do to get rid of it!?

Thanks
-D
0
Comment
Question by:indacrypt
  • 4
  • 2
  • 2
8 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 250 total points
ID: 18751574
The corresonding control is not existing (anymore), maybe you renamed the resource ID. This method is called when you create (or display?) your dialog, for all controls having a member variable assigned. All such controls are enumerated in DDX_... macros.
Have a look on the resource ID in this method, and what that correspnds to.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18754419
What was the line of code you changed?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 18754714
... the most important question, this is ...
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 250 total points
ID: 18754736
Look at where the ASSERT(FALSE)  line is in the code - it *could* be something completely different to what your comment suggested.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:indacrypt
ID: 18755573
Hi Andy...can u pls explain what you meant by "Look at where the ASSERT(FALSE)  line is in the code -"....Im not able to find that line anywhere in the code other than i nthe place pointed to b ythe debugger....
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18755591
comment meant for Qlemo.  His comment is likely to be correct but..

indacrypt - what line of code did you change?  Then we would know if Qlemo has got it right or not.
0
 

Author Comment

by:indacrypt
ID: 18755624
ok i see wht you meant....i followed the IDC number from the ASSERT line and found there are two controls by that number. I have to figureout which one hass the problem now I guess. Thanks!
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18755770
I don't think the resource editor will allow two controls with the same ID on the same dialog (apart from the special IDC_STATIC that is).
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now