Problem: "Debug Assertion Failed"?

After adding some code to a project and some controls to a dialog in
the project, when I run the program I get the following error dialog:

Debug Assertion Failed!

Program: {path to my program executable and executable name}
File:  afxwin2.inl
Line: 590

followed by an application error dialog.

I am not using asserts in my code and when I remove conrols from the
dialog, the line number changes.  Any idea what might be causing this
or where to look for a cause?  Is there a limit to the number of
controls on a dialog?  (There are about 150 on this one.  It is a data
readout dialog for a piece of test equipment.)

Thanks!

Don

0
emq_33 (6)
2/16/2006 6:40:18 PM
vc.mfc 33608 articles. 0 followers. Follow

10 Replies
1076 Views

Similar Articles

[PageSpeed] 12

Don wrote:
> After adding some code to a project and some controls to a dialog in
> the project, when I run the program I get the following error dialog:
>
> Debug Assertion Failed!
>
> Program: {path to my program executable and executable name}
> File:  afxwin2.inl
> Line: 590
>
> followed by an application error dialog.
>
> I am not using asserts in my code and when I remove conrols from the
> dialog, the line number changes.  Any idea what might be causing this
> or where to look for a cause?  Is there a limit to the number of
> controls on a dialog?  (There are about 150 on this one.  It is a data
> readout dialog for a piece of test equipment.)

Yeah, you can only have 256 controls on one dialog.  The error you're
getting doesn't have to do with that, however.  What is on line 590?
Have you tried double clicking the error message to bring you to the
error?  

Regards,
Ben

0
henrybg (59)
2/16/2006 6:56:01 PM
Take a look at the stack and see which line in *your* code is causing
this assertion. Its your code is which is responsible for this issue.
For more help, show your code.

---------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6841)
2/16/2006 7:00:00 PM
Don wrote:

> After adding some code to a project and some controls to a dialog in
> the project, when I run the program I get the following error dialog:
> 
> Debug Assertion Failed!
> 
> Program: {path to my program executable and executable name}
> File:  afxwin2.inl
> Line: 590
> 
> followed by an application error dialog.
> 
> I am not using asserts in my code and when I remove conrols from the
> dialog, the line number changes.  Any idea what might be causing this
> or where to look for a cause?  Is there a limit to the number of
> controls on a dialog?  (There are about 150 on this one.  It is a data
> readout dialog for a piece of test equipment.)
> 
> Thanks!
> 
> Don
> 

Don:

You need to run under the debugger (or hit Retry to allow JIT to attach 
to the debugger) and look at the call stack. You should be able to go to 
the line in afxwin2.inl and see what it didn't like. You can also follow 
back up in the call stack until you reach your own code, and therefore 
see what line of your code caused the problem.

I think there may be a limit of 255 controls on a dialog, so that should 
not be the problem. However, IMHO, 150 is way too many. If these are 
edit controls that are just displaying data, you don't really need them. 
Even if you need to be able to edit the values, what you really want is 
an editable grid control (such beasts do not assign an edit control to 
every cell -- can you imagine what would happen if Excel did that?).

David Wilkinson

0
no-reply8010 (1790)
2/16/2006 7:02:07 PM
Your are setting an icon to a control does has not been created or does not 
exist.

Below if the line that failed, 590: ASSERT(::IsWindow(m_hWnd));.

_AFXWIN_INLINE HICON CStatic::SetIcon(HICON hIcon)
	{ ASSERT(::IsWindow(m_hWnd)); return (HICON)::SendMessage(m_hWnd, 
STM_SETICON, (WPARAM)hIcon, 0L); }

"David Wilkinson" wrote:

> Don wrote:
> 
> > After adding some code to a project and some controls to a dialog in
> > the project, when I run the program I get the following error dialog:
> > 
> > Debug Assertion Failed!
> > 
> > Program: {path to my program executable and executable name}
> > File:  afxwin2.inl
> > Line: 590
> > 
> > followed by an application error dialog.
> > 
> > I am not using asserts in my code and when I remove conrols from the
> > dialog, the line number changes.  Any idea what might be causing this
> > or where to look for a cause?  Is there a limit to the number of
> > controls on a dialog?  (There are about 150 on this one.  It is a data
> > readout dialog for a piece of test equipment.)
> > 
> > Thanks!
> > 
> > Don
> > 
> 
> Don:
> 
> You need to run under the debugger (or hit Retry to allow JIT to attach 
> to the debugger) and look at the call stack. You should be able to go to 
> the line in afxwin2.inl and see what it didn't like. You can also follow 
> back up in the call stack until you reach your own code, and therefore 
> see what line of your code caused the problem.
> 
> I think there may be a limit of 255 controls on a dialog, so that should 
> not be the problem. However, IMHO, 150 is way too many. If these are 
> edit controls that are just displaying data, you don't really need them. 
> Even if you need to be able to edit the values, what you really want is 
> an editable grid control (such beasts do not assign an edit control to 
> every cell -- can you imagine what would happen if Excel did that?).
> 
> David Wilkinson
> 
> 
0
frug (6)
2/16/2006 7:34:26 PM
Based on everyone's comments, I think it is a problem with the number
of controls.  It runs in my mind from somewhere (might be Access) that
even if a control has been deleted it still counts against the total.

Any suggestions on how to lay out data on a dialog?  Some sort of grid
control maybe?

Suggestions welcomed and appreciated!

Thanks for all the comments!

Don

0
emq_33 (6)
2/16/2006 7:48:29 PM
> I think it is a problem with the number of controls.

I dont think you can deduce this from the discussion. These are two
different issues.  Its not really difficult to look at the line of your
code thats causing this assert.

> Any suggestions on how to lay out data on a dialog?  Some sort of grid
> control maybe?

It depends upon what you have. If you have bunch of edit controls laid
out in an rectangular array, look at listcontrol/grid control.

Depending upon what you have, you can also use Tabs in your dialog.
Only show a group of controls that are related.

-------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6841)
2/16/2006 7:58:39 PM
The data is about 75% binary (i.e. True/False) so I was using check
boxes for those.  The remainder are edit controls.  Quite honestly, I
even thought it was getting getting a bit unweildy.  This little "bump
in the road" has just pushed up looking at alternatives.

At one point, I did consider a tab control with each message on it's
own tab.  But how would this play into the overall limit of 255
controls?  Is the limit of 255 on the entire dialog?  Or will each tab
have a limit of 255?  Or am I confused on this point and there is no
limit?

Right now, a grid control (sort of like cells in Excel) would probably
be sufficient.  A quick check in the MFC help and the one reference
book I have did not turn up anything.  Is this something I would find
at SourceForge or CodeProject?  Or am I missing a built in one?

Thanks!

Don

0
emq_33 (6)
2/16/2006 9:02:05 PM
MFC does not have a grid control. Best you can do it is use a list
control. The one at codeproject is very popular:

http://www.codeproject.com/miscctrl/gridctrl.asp

I have not used it. We have been using a commercial product (Ultimate
Grid) and it serves our purpose.

----------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6841)
2/16/2006 9:06:39 PM
Thanks Ajay!

Don


Ajay Kalra wrote:
> MFC does not have a grid control. Best you can do it is use a list
> control. The one at codeproject is very popular:
>
> http://www.codeproject.com/miscctrl/gridctrl.asp
>
> I have not used it. We have been using a commercial product (Ultimate
> Grid) and it serves our purpose.
> 
> ----------
> Ajay Kalra
> ajaykalra@yahoo.com

0
emq_33 (6)
2/17/2006 12:01:59 AM
"Don" <emq_33@hotmail.com> wrote in message 
news:1140120648.375432.287100@g44g2000cwa.googlegroups.com...
> The data is about 75% binary (i.e. True/False) so I was using check
> boxes for those.  The remainder are edit controls.  Quite honestly, I
> even thought it was getting getting a bit unweildy.  This little "bump
> in the road" has just pushed up looking at alternatives.
>
> At one point, I did consider a tab control with each message on it's
> own tab.  But how would this play into the overall limit of 255
> controls?  Is the limit of 255 on the entire dialog?  Or will each tab
> have a limit of 255?  Or am I confused on this point and there is no
> limit?
>
> Right now, a grid control (sort of like cells in Excel) would probably
> be sufficient.  A quick check in the MFC help and the one reference
> book I have did not turn up anything.  Is this something I would find
> at SourceForge or CodeProject?  Or am I missing a built in one?

Take a look at CCheckListBox  in the MSDN documentation. It likely provides 
the functionality that you need.

-Pete 


0
Pete4450 (53)
2/17/2006 4:55:17 PM
Reply:

Similar Artilces:

Tips to hide "Debug Assertion Failed!"
I am using Visual Studio 6.0 to develop a GUI software. Sometimes when I tested the software in a different OS, I can get the following error message: "Microsoft Visual C++ Debug Library Debug Assetion Failed! Program:... File: ... Line: ..." I do not like this kind of message box being displayed, since it looks like that I am releasing a "debug" version. In case there is an error occurred, I would like to use my own warning message box instead. For example, I would like to show "You have encountered a problem caused by your operating system. Try to run the sof...

show Image with CImage
Hi, I tried to show a png Image using CImage ( Visual Studio 2008 prof ) It works pretty good, but only in Release Mode. If I run it in Debug Mode there is a Message: "Debug Assertion Failed! Program: ....[..]\application.exe File: g:[...]\atlimage.h Line: 503 Expression: m_hbitmap == 0 [..] if I ignore the message the picture is schown. How can I avoid this Failure My Code: BOOL OK; LPCTSTR lpBitSource=_T("D:\\Daten\\Visual Studio 2008\\Projects\\LitLaunchTestbox\\LitLaunch\\brett1.png"); CRect rect; GetClientRect(&rect); CWindowDC...

Debug Assertion Failed
I have been getting the following error message: Debug Assertion Failed! Program:Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE File: j:\olxpeer\wkslib\rpccommon.cpp Line: 114 For information on how your program can cuase an assertion failure, see the Visul C++ documentation on asserts (Press Retry to debug the application) Any ideas what is causing it? Regards, Jon ...

Debug Assertion Failed #3
I have the following code in my thread: while (true) { FData * pData = new FData(); ..... ..... ..... if (something==true) { Sleep(1000); delete pData ; continue; } } i get Debug Assertion Failed because of the delete pData. Why? Regards, Mystique Assuming pData is properly allocated, deleting should not cause the assert. You dont show the line of code where the assert is coming from. Are you using pData after it has been deleted? ----- Ajay Kalra ajaykalra@yahoo.com Mystique wrote: > i get Debug Assertion Failed because of t...

Problem: "Debug Assertion Failed"?
After adding some code to a project and some controls to a dialog in the project, when I run the program I get the following error dialog: Debug Assertion Failed! Program: {path to my program executable and executable name} File: afxwin2.inl Line: 590 followed by an application error dialog. I am not using asserts in my code and when I remove conrols from the dialog, the line number changes. Any idea what might be causing this or where to look for a cause? Is there a limit to the number of controls on a dialog? (There are about 150 on this one. It is a data readout dialog for a piece ...

Debug assertion failed with CListCtrl...
In an SDI application I am creating I want to create a listview in my child window (not a dialog), much like Windows Explorer. I create an array of filenames in OnNewDocument in my Document class. Then, in my View class, I want to create a listview with just one column containing these strings. My code is as follows: // NOTES: // m_documentList is a member variable of the view class // pDoc->m_files is an array of CStrings CArchieDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // get the size of the view window CRect rect; this->GetClientRect( &rect ); // create list view m_...

Debug assertion failed trying to CAsyncSocket::Connect()
Hi, I have a client (locally) trying to connect to a server locally. If i connect (using CAsyncSocket::Connect()) with the IP that IPconfig gives, i get a debug assertion failed. After pressing the RETRY button on the debug assertion failed dialog the source goes to : /* * If this ASSERT fails, a bad pointer has been passed in. It may be * totally bogus, or it may have been allocated from another heap. * The pointer MUST come from the 'local' heap. */ _ASSERTE(_CrtIsValidHeapPointer(pUserData)); in dbgheap.cpp If i connect on 127.0.0.1 e...

Problem: "Debug Assertion Failed", File:afxcmn.inl
Hi, I have created an ActiveX ocx control in VC++6.0. When I run it in an ActiveX container of TSTCON32.exe. (the one that is shown while debugging) it runs perfectly. Iam trying to include it in a webpage (I am using visual-interdev for web page creation) by first customizing the toolbox for that ActiveX control and then dragging it to the web page from the toolbox. As soon as I drag it to the webpage, the IDE crashes with a message "Debug Assertion Failed", File:afxcmn.inl Can u suggest me why the problem is occurring and whets the probable solution. Thanks in advance Vijay...

Debug Assertion Failed
First the problem, then I'll attempt to post all of the info I think may be pertinent. I get the following message when I try to register a dll on a machine other than the one I built it on Debug Assertion Failed Program: C:\B7\DV7333\bin32\REGSVR32.EX File: olelink.cp Line: 29 When developing, it builds fine and I am able to register it on the development machine This is an MFC dll which implements the class wizard generated: DllGetClassObject, DllCanUnloadNow, and DllRegisterServer functions I have used depends.exe on the target machine and all it's dependcies are accounted for...

Debug Assertion Failed!
Hi Pals, I am trying to create a application like Wanderer, a sample app provided by MS. I have created a SDI application using MFC wizard. I have attacted a TreeCtrl for display the Drives those are in my system. When i am trying to run my app, i am getting this following Error in popup window, Debug Assertion Failed! File: winsplit.cpp Line: 364 I tried via debug mode by setting breakpoints. if (!ProcessShellCommand(cmdInfo)) return FALSE; On this line i am geeting the err information. Give me a good solutions for how to eradicate this situation? Regards, Seenu. Infovation Inc. ...

Debug Assertion Failed (_CrtCheckMemory)
We have a console application which has been built with VC++ 6.0 (pure C++ project) and runs without any runtime errors. But when the same project has been ported to VC++ 7.0 environment, application asserts as "Debug Assertion Failed" (dbgheap.c, line 1100 & 346, _CrtCheckMemory). It continues to run, if the assertion is ignored at several places. Could anyone throw light on why this could happen specifically. (We have already digged through mixed usage of new, malloc, delete, delete[], free etc.,) If anything else corrupts heap memory, please suggest the same. Thanks ...

Debug Assertion Failed #5
Hi, I have an application that I support that was developed with VS6, 7, and now I am using VS2005. It is being installed and tested on a PC elsewhere. The person testing it for me is having a runtime issue with the following message, Debug Assertion Failed! names the executale with this line after, File f:\rtm\vctools\vc7libs\ship\atlmfc\include\atlsimpstr.h Expression: (iChar >=0) && (iChar <= GetLength()) Almost seems like the wrong lib is being used on the test machine, vc7libs. Should that be vc8 since I am using VS 2005? Not sure what to make of this. The application work...

Debug assertion Failed! #4
Hi all! I have created an mfc application that would create a text file containing a comma-separated data. These data from the text file can be imported to Excel. Here's the scenario: I have generated/created a .txt file using the MFC application (ex. MyData.txt). After that, i opened the "MyData.txt" file in the Excel application: File-> Open-> MyData.txt-> Select 'Delimited' & Next-> Select 'Comma' & Finish The data was then imported by the Excel application. Afterwards, i run the MFC application again and created a .txt file with ...

Debug Assertion Failed #4
Hi, when i create a new second form and add in FileOnPrint and FileOnPrintPreview command from the MFC classwizard. On the Constructor, i added the following code: void CProduct::OnFilePrint() { // TODO: Add your command handler code here CFormView::OnFilePrint() ; // code added } when execute and press the print button to test whether it is working or not, I got the following error: Debug Assertion Failed. File: viewprnt.ccp Line: 161 How do I remedy the problem. Thanks. Newbie & Noobie wrote: > Hi, > when i create a new second form and add in FileOnPrint and > Fi...

Debug Assertion Failed! #3
Hi, I have a MFC project written by VS2005, the project has been put into use for almost 1 year, but recently when I execute this program ,it will turn out the following problem, Debug Assertion Failed! Program F:\.......\MyProject.exe File: F:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp Line: 329 For information... Could anybody give me a help, thanks in advance! -ja Kinda hard to debug without some code to look at "jos" <josndrsn@yahoo.com> wrote in message news:#fiw6S3dIHA.1208@TK2MSFTNGP03.phx.gbl... > Hi, > I have a MFC project written ...

Debug Assertion Failed! #2
While running my program in debug mode, I had the next problem and can't find out what's wrong. ------ Debug Assertion Failed! Program: c:\VC7\test.exe File : Occmgr.cpp Line: 410 Unhandled exception at 0x7c1a9b1e (mfc71d.dll) in test.exe: User breakpoint. ------ The last line in my code from where the mfc71d.dll is called is. BOOL CMediaPlanFrm::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { CSplitterWnd m_wndSplitter; if ( m_wndSplitter.CreateStatic( this, 2, 1 ) ) { m_wndSplitter.CreateView( 0, 0, RUNTIME_CLASS(CPlanboardView), CSize(400,350), pContext); // &...

Debug Assertion Failed #2
Hi, What is wrong with this bit of code please if(message == WM_COPYDATA) { WmCpyDta_SetEncrypt('d'); WmCpyDta_SetMessageId(WmCpyDta_BaseDefaultMsgId()); CString strTag, strData; WmCpyDta_SendMessage_TI_SetCountMsg(NULL, NULL, lParam, strTag.GetBuffer(0), strData.GetBuffer(0)); m_ctrlAddress.SetWindowText(strData); m_ctrlCount.SetWindowText(strTag); strData.ReleaseBuffer(); strTag.ReleaseBuffer(); } I get a Debug Assertion Failed error with the expression line as nLength <= GetData()->nAllocLength ...

Debug Assertion Failed by using CView
Hi everybody! I'm using VisualC++6 with MFC. I have a assert when I quit my program (SDI) Here is the code: I created Document templates : CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyListViewDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CMyView)); In my CMyView class, I've got a member variable : protected: CView2 m_View; with class CView2 : class CViewExt:public CView { public: CViewExt(); DECLARE_DYNCREATE(CViewExt) virtual ~CViewExt(); virtual void OnDraw(CDC* pDC); }; For Creating a new view, I do i...

afxwin1.inl
I am running the debugger in VC++ 6.0. It says the assert is on the following line (27): { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } This happens when one of my dlls is executing. I tried adding the following as a global in the main code, but this did not help. CWinApp MyApp("xxxx"); // attempted to remove assert Also, I use multiple dlls. One of the dll's uses MFC (not the new problematic one) and is a normal dynamically linked dll. (use MFC shared dll and NO DllMain). Any ideas on how to fix the assert? TIA! Is it possible that you need to...

Debug Assertion Failed! File: winocc.cpp
In my COM Server i have added Dialog Box. i have registered OCX file and added that Activex Control to my Project also. It has created 1 header file and 1 source file. After that i have created an instance(object) of that ActiveX control and trying to call functions, But its giving run time error. Debug Assertion Filed! File: winocc.cpp Line: 345 Please help me karspy@gmail.com wrote: > In my COM Server i have added Dialog Box. i have registered OCX file > and added that Activex Control to my Project also. It has created 1 > header file and 1 source file. > > After that i...

using CFileException
When I call "GetErrorMessage" on the CFileException object, as in the following snipet, I get a "Debug Assertion Failed!" error dialog: Code snipet: ---------------------------------------------------------------------------- CString fileName = _T("C:\\someFile.xsd"); CFile XSDFile; CFileException fileException; if ( !XSDFile.Open(fileName, CFile::modeRead, &fileException) ) { // Problem opening the file, determine error TCHAR errCause[1024]; //TODO - Debug assertion raised on this line, why?? fileException.GetErrorMessage(errCause, 1024); ...

Debug Assertion failed while deleting a CObject derived class
Hello, after some changes in Visual project settings I got=20 an=20 "debug assertion failed File: dbgheap.c Line: 1084 Expression: pHead->nBlockUse=3D=3DnBlockUse" The error occcurs at the last line of the following code=20 section: ------------------------------------------------------ CMobiles* test =3Dnew CMobile; if(test=3D=3DNULL) AfxMessageBox("Allocation error"); delete test; ------------------------------------------------------ The error occurs only if "CMobile" is derived from=20 CObject. It is independent how simple "CMobile" is. ...

Debug assertion failed (in afxwin1.inl) line 21
Hi, I have an application using MFC. The application code is compiling fine But when the application is executed using debug mode following error is getting generated: Debug Assertion Failed! File: f:\..\..\afxwin.inl Line: 21 Hope somebody could help me out by advising what may be wrong with my code!! On 17 Feb 2007 10:26:13 -0800, "abhichamp" <abhigup1986@gmail.com> wrote: >Hi, > >I have an application using MFC. The application code is compiling >fine >But when the application is executed >using debug mode following error is getting generated...

using CFileException
When I call "GetErrorMessage" on the CFileException object, as in the following snipet, I get a "Debug Assertion Failed!" error dialog: Code snipet: ---------------------------------------------------------------------------- CString fileName = _T("C:\\someFile.xsd"); CFile XSDFile; CFileException fileException; if ( !XSDFile.Open(fileName, CFile::modeRead, &fileException) ) { // Problem opening the file, determine error TCHAR errCause[1024]; //TODO - Debug assertion raised on this line, why?? fileException.GetErrorMessage(errCause, 1024); ...

debug assertion failed. File: cmdtarg.cpp Line:52
Hi, I made a MFC ActiveX with a CwinThread Class in VC ++. Then i used it on Visual basic. When i try to make an exe i got this error : Debug Assertion Failed! Program: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VB98\VB6.EXE File: cmdtarg.cpp Line: 52 For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press Retry to debug the application) A microsoft website says that this bug was corrected in the latest service pack for Visual Studio 6.0. But i already have the latest service pack and this error still occurs. Can anyone tell m...